List of usage examples for org.springframework.transaction.support TransactionSynchronizationManager bindResource
public static void bindResource(Object key, Object value) throws IllegalStateException
From source file:org.iwethey.forums.db.test.HibernateTestHarness.java
public void setUp() throws Exception { SessionFactory sf = (SessionFactory) this.context.getBean("sessionFactory"); //Session s = SessionFactoryUtils.getSession(sessionFactory, true); // open and bind the session for this test thread. Session s = sf.openSession();//from w ww . j a v a 2s .com TransactionSynchronizationManager.bindResource(sf, new SessionHolder(s)); }
From source file:org.codehaus.groovy.grails.plugins.quartz.listeners.SessionBinderJobListener.java
public void jobToBeExecuted(JobExecutionContext context) { Session session = SessionFactoryUtils.getSession(sessionFactory, true); session.setFlushMode(FlushMode.AUTO); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); if (LOG.isDebugEnabled()) LOG.debug("Hibernate Session is bounded to Job thread"); }
From source file:com.healthcit.cacure.model.GetAllForms.java
@Before public void setUp() { // EntityManagerFactory emf = (EntityManagerFactory)context.getBean("entityManagerFactory"); EntityManager em = emf.createEntityManager(); TransactionSynchronizationManager.bindResource(emf, new EntityManagerHolder(em)); }
From source file:org.parancoe.web.ParancoeOpenSessionInViewInterceptor.java
@Override public boolean preHandle(HttpServletRequest req, HttpServletResponse res, Object handler) throws Exception { logger.debug("Opening session and beginning transaction"); Session session = sessionFactory.openSession(); session.beginTransaction();/*w ww . j a v a2 s .c o m*/ if (!TransactionSynchronizationManager.hasResource(sessionFactory)) { TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); TransactionSynchronizationManager.initSynchronization(); } return true; }
From source file:ch.algotrader.hibernate.InMemoryDBTest.java
@Before public void setup() throws Exception { ResourceDatabasePopulator dbPopulator = new ResourceDatabasePopulator(); dbPopulator.addScript(new ClassPathResource("/db/h2/h2.sql")); DatabasePopulatorUtils.execute(dbPopulator, EmbeddedTestDB.DATABASE.getDataSource()); this.sessionFactory = EmbeddedTestDB.DATABASE.getSessionFactory(); this.session = this.sessionFactory.openSession(); TransactionSynchronizationManager.bindResource(this.sessionFactory, new SessionHolder(this.session)); }
From source file:com.healthcit.cacure.businessdelegates.export.DataImporterTest.java
@Before public void setUp() { EntityManager em = emf.createEntityManager(); TransactionSynchronizationManager.bindResource(emf, new EntityManagerHolder(em)); login("lkagan", "koala"); }
From source file:corner.orm.hibernate.impl.SpringSessionManagerImpl.java
public SpringSessionManagerImpl(HibernateSessionSource source) { sessionFactory = source.getSessionFactory();// single session mode if (TransactionSynchronizationManager.hasResource(sessionFactory)) { // Do not modify the Session: just set the participate flag. participate = true;/*w w w . ja va 2 s .c om*/ } else { logger.debug("Opening single Hibernate Session in OpenSessionInViewFilter"); Session session = getSession(sessionFactory); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); } }
From source file:org.motechproject.server.omod.sdsched.TxSyncManWrapperImpl.java
public void bindResource(String resourceName, Object obj) { TransactionSynchronizationManager.bindResource(resourceName, obj); }
From source file:org.grails.datastore.mapping.transactions.support.SpringSessionSynchronization.java
public void resume() { if (holderActive) { TransactionSynchronizationManager.bindResource(datastore, sessionHolder); } }
From source file:org.openeos.services.ui.vaadin.internal.OpenSessionInViewListener.java
@Override public void onTransactionStart(IUnoVaadinApplication application) { if (sessionFactory != null) { if (TransactionSynchronizationManager.hasResource(sessionFactory)) { LOG.debug("Participating in existing open session."); } else {// www. j a v a 2 s .co m LOG.debug("Opening session in View..."); Session session = SessionFactoryUtils.openSession(sessionFactory); session.setFlushMode(FlushMode.MANUAL); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); tlSession.set(session); } } }