我有@Transactional方法的Spring bean。Spring @Transactional注释的严格替代
public class ABean{
@Transactional
public void method aMethod(){
//do some job with Hibernate.
}
}
但现在我需要(实际上是在石英上下文)调用从不应在Spring上下文中被称为另一种方法,这种方法:
public class ABean implements org.quartz.Job{
@Transactional
public void method aMethod(){
//do some job with Hibernate.
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("start...");
//@Transactional annotation is ignored here
//so I have 'Could not obtain transaction-synchronized Session
//for current thread' exception.
aMethod();
System.out.println("done");
}
}
据我了解注解@Transactional只是不知何故包装方法与另一些代码。那么我怎么必须包装aMethod()调用才能完全像Spring调用一样调用它?
[Spring @Transaction方法调用由同一类中的方法调用可能的副本,不起作用?](http://stackoverflow.com/questions/3423972/spring-transaction-method-call-by-the-方法在同一班,不禾窝) –