session2Control.replay();
JtaTransactionManager ptm = new JtaTransactionManager();
ptm.setUserTransaction(ut);
ptm.setTransactionManager(tm);
final TransactionTemplate tt = new TransactionTemplate(ptm);
tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
try {
tt.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
org.hibernate.Session outerSession = SessionFactoryUtils.getSession(sf, false);
assertSame(session1, outerSession);
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
assertTrue("Has thread session", holder != null);
try {
tt.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
org.hibernate.Session innerSession = SessionFactoryUtils.getSession(sf, false);
assertSame(session2, innerSession);
HibernateTemplate ht = new HibernateTemplate(sf);
ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);