sessionControl.setReturnValue(null, 1);
sfControl.replay();
sessionControl.replay();
JtaTransactionManager tm = new JtaTransactionManager(ut);
TransactionTemplate tt = new TransactionTemplate(tm);
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_SUPPORTS);
final TransactionTemplate tt2 = new TransactionTemplate(tm);
tt2.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
tt.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
assertTrue("Is not new transaction", !status.isNewTransaction());
assertFalse(TransactionSynchronizationManager.isCurrentTransactionReadOnly());
assertFalse(TransactionSynchronizationManager.isActualTransactionActive());
HibernateTemplate ht = new HibernateTemplate(sf);
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
ht.execute(new HibernateCallback() {
public Object doInHibernate(org.hibernate.Session session) {
return null;
}
});
assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
tt2.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
HibernateTemplate ht = new HibernateTemplate(sf);
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
return ht.executeFind(new HibernateCallback() {
public Object doInHibernate(org.hibernate.Session session) {