/** * Look for the TopiaPersistenceContext based on the given Hibernate session * * @param event the Hibernate event that contains the Session to use * @return the TopiaPersistenceContext using this Session, or null if not found */ protected TopiaPersistenceContext getContext(AbstractEvent event) { EventSource session = event.getSession(); TopiaPersistenceContext result = registry.getPersistenceContext(session); return result; }
sessionRegistry.register(result, this); sessionRegistry.unregister(result); } catch (HibernateException e1) { if (log.isErrorEnabled()) {
protected void init() { new TopiaConfigurationBuilder().check(configuration); topiaFiresSupport = new TopiaFiresSupport(); sessionRegistry = new TopiaHibernateSessionRegistry(); // First initialize all the services initServices(); // ToPIA's schema init if (isInitSchema()) { if (log.isInfoEnabled()) { log.info("Schema initialization enabled"); } initSchema(); } else { if (log.isInfoEnabled()) { log.info("Schema initialization disabled"); } } // AThimel 14/06/14 Make sure this method is called AFTER ToPIA's schema init, otherwise Hibernate may have created the schema itself // The next line will trigger the Configuration#buildMappings() method which really initializes Hibernate getHibernateProvider().getHibernateConfiguration(); }
protected void rollback0(boolean beginAfterRollback) { try { Session hibernateSession = hibernateSupport.getHibernateSession(); Transaction transaction = hibernateSession.getTransaction(); hibernateSession.clear(); transaction.rollback(); hibernateSession.close(); sessionRegistry.unregister(hibernateSession); if (beginAfterRollback) { // it's very important to change the session after rollback // otherwise there are many error during next Entity's modification hibernateSession = hibernateSupport.getHibernateFactory().openSession(); hibernateSupport.setHibernateSession(hibernateSession); hibernateSession.setFlushMode(FlushMode.MANUAL); sessionRegistry.register(hibernateSession, this); hibernateSession.beginTransaction(); } getTopiaFiresSupport().fireOnPostRollback(this); } catch (HibernateException eee) { String message = String.format("An error occurred during rollback operation: %1$s", eee.getMessage()); throw new TopiaException(message, eee); } }