The project I am working on has a similar structure for the DAOs to the one bellow:
/**
* Base DAO class
*/
@Transactional
public class JPABase {
@PersistenceContext
private EntityManager entityManager;
public void persist(Object entity) {
entityManager.persist(entity);
}
//some more methods in here
}
and
/**
* Generic DAO class implementation
*/
@Transactional
public abstract class GenericDao extends JpaBase {
//some methods in here
}
and
/**
* Specialized DAO class
*/
@Repository
@Transactional
public class PersonDao extends GenericDao {
//some methods in here
}
Until now, the project used compile time weaving, but the configuration has changed to use <context:load-time-weaver/> with -javaagent:/opt/tomcat7-1/lib/spring-instrument.jar.
Since this change has been applied, the JpaBase's and GenericDao's @Transactional annotations are not weaved anymore. Each time a service class calls the persist method on a PersonDao object, no transaction is started.
Noteworthy:
- this used to work in the past, when using compile time weaving.
- all the methods that are defined in the
PersonDaoare weaved correctly, but the ones inherited (e.g.persist(Object entity)) are NOT weaved.
Compile time weaving and load time weaving are supposed to do the same thing, just at different moments in time. Why has the weaving behaviour changed?