public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getHibernateSession(session.getParent())); } } }
public void sessionEnded(RequestContext context, FlowSession session, String outcome, AttributeMap<?> output) { if (isParentPersistenceContext(session)) { if (!isPersistenceContext(session.getDefinition())) { bind(getEntityManager(session.getParent())); } } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { setHibernateSession(session, getHibernateSession(session.getParent())); reusePersistenceContext = true; } else { unbind(getHibernateSession(session.getParent())); } } if (isPersistenceContext(session.getDefinition()) && (!reusePersistenceContext)) { Session hibernateSession = createSession(context); setHibernateSession(session, hibernateSession); bind(hibernateSession); } }
public void sessionStarting(RequestContext context, FlowSession session, MutableAttributeMap<?> input) { boolean reusePersistenceContext = false; if (isParentPersistenceContext(session)) { if (isPersistenceContext(session.getDefinition())) { setEntityManager(session, getEntityManager(session.getParent())); reusePersistenceContext = true; } else { unbind(getEntityManager(session.getParent())); } } if (isPersistenceContext(session.getDefinition()) && (!reusePersistenceContext)) { EntityManager em = entityManagerFactory.createEntityManager(); session.getScope().put(PERSISTENCE_CONTEXT_ATTRIBUTE, em); bind(em); } }
public void paused(RequestContext context) { if (isPersistenceContext(context.getActiveFlow())) { unbind(getEntityManager(context.getFlowExecutionContext().getActiveSession())); } }
public void exceptionThrown(RequestContext context, FlowExecutionException exception) { if (context.getFlowExecutionContext().isActive()) { if (isPersistenceContext(context.getActiveFlow())) { unbind(getHibernateSession(context.getFlowExecutionContext().getActiveSession())); } } }
public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap<?> output) { if (isParentPersistenceContext(session)) { return; } if (isPersistenceContext(session.getDefinition())) { final EntityManager em = getEntityManager(session); Boolean commitStatus = session.getState().getAttributes().getBoolean("commit"); if (Boolean.TRUE.equals(commitStatus)) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { em.joinTransaction(); } }); } unbind(em); em.close(); } }
public void sessionEnding(RequestContext context, FlowSession session, String outcome, MutableAttributeMap<?> output) { if (isParentPersistenceContext(session)) { return; } if (isPersistenceContext(session.getDefinition())) { final Session hibernateSession = getHibernateSession(session); Boolean commitStatus = session.getState().getAttributes().getBoolean("commit"); if (Boolean.TRUE.equals(commitStatus)) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { sessionFactory.getCurrentSession(); // nothing to do; a flush will happen on commit automatically as this is a read-write // transaction } }); } unbind(hibernateSession); hibernateSession.close(); } }
public void resuming(RequestContext context) { if (isPersistenceContext(context.getActiveFlow())) { bind(getEntityManager(context.getFlowExecutionContext().getActiveSession())); } }
public void resuming(RequestContext context) { if (isPersistenceContext(context.getActiveFlow())) { bind(getHibernateSession(context.getFlowExecutionContext().getActiveSession())); } }
protected void setUp() throws Exception { DataSource dataSource = getDataSource(); populateDataBase(dataSource); jdbcTemplate = new JdbcTemplate(dataSource); hibernate = HibernateHandlerFactory.create(dataSource); hibernateListener = new HibernateFlowExecutionListener(hibernate.getSessionFactory(), hibernate.getTransactionManager()); }
@Override protected void assertCommitState(boolean insertRow, boolean isCommited) { if (insertRow) { hibernate.templateSave(new TestBean(rowCount++, "Keith Donald")); } if (!isCommited) { assertEquals("Nothing should be committed yet", 1, getCount()); } else { assertEquals("All rows should be committed", rowCount, getCount()); } }
@Override protected void setUpResources(DataSource dataSource) throws Exception { hibernate = HibernateHandlerFactory.create(dataSource); executionListener = new HibernateFlowExecutionListener(hibernate.getSessionFactory(), hibernate.getTransactionManager()); rowCount = 1; }
private boolean isParentPersistenceContext(FlowSession flowSession) { return ((!flowSession.isRoot()) && isPersistenceContext(flowSession.getParent().getDefinition())); }
private boolean isParentPersistenceContext(FlowSession flowSession) { return ((!flowSession.isRoot()) && isPersistenceContext(flowSession.getParent().getDefinition())); }
@Override protected FlowExecutionListener createFlowExecutionListener() throws Exception { sessionFactory = getSessionFactory(getDataSource()); HibernateTransactionManager tm = new HibernateTransactionManager(sessionFactory); return new HibernateFlowExecutionListener(sessionFactory, tm); }
@Override protected FlowExecutionListener createFlowExecutionListener() { entityManagerFactory = getEntityManagerFactory(getDataSource()); JpaTransactionManager tm = new JpaTransactionManager(entityManagerFactory); return new JpaFlowExecutionListener(entityManagerFactory, tm); }
@Override protected void setUpResources(DataSource dataSource) throws Exception { entityManagerFactory = getEntityManagerFactory(dataSource); JpaTransactionManager tm = new JpaTransactionManager(entityManagerFactory); executionListener = new JpaFlowExecutionListener(entityManagerFactory, tm); rowCount = 1; }
public void exceptionThrown(RequestContext context, FlowExecutionException exception) { if (context.getFlowExecutionContext().isActive()) { if (isPersistenceContext(context.getActiveFlow())) { unbind(getEntityManager(context.getFlowExecutionContext().getActiveSession())); } } }
public void paused(RequestContext context) { if (isPersistenceContext(context.getActiveFlow())) { Session session = getHibernateSession(context.getFlowExecutionContext().getActiveSession()); unbind(session); session.disconnect(); } }