101102103104105106107108109
public static void rebuildSessionFactory() throws InfrastructureException { synchronized (sessionFactory) { try { sessionFactory = getConfiguration().buildSessionFactory(); } catch (Exception ex) { throw new InfrastructureException(ex); } } }
117118119120121122123124125
synchronized (sessionFactory) { try { sessionFactory = cfg.buildSessionFactory(); configuration = cfg; } catch (Exception ex) { throw new InfrastructureException(ex); } } }
142143144145146147148149150
s = getSessionFactory().openSession(); } threadSession.set(s); } } catch (HibernateException ex) { throw new InfrastructureException(ex); } return s; }
158159160161162163164165
threadSession.set(null); if (s != null && s.isOpen()) { s.close(); } } catch (HibernateException ex) { throw new InfrastructureException(ex); } }
174175176177178179180181
log.debug("Starting new database transaction in this thread."); tx = getSession().beginTransaction(); threadTransaction.set(tx); } } catch (HibernateException ex) { throw new InfrastructureException(ex); } }
191192193194195196197198
tx.commit(); } threadTransaction.set(null); } catch (HibernateException ex) { rollbackTransaction(); throw new InfrastructureException(ex); } }
207208209210211212213214215216
if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { log.debug("Tyring to rollback database transaction of this thread."); tx.rollback(); } } catch (HibernateException ex) { throw new InfrastructureException(ex); } finally { closeSession(); } }
228229230231232233234235236
threadSession.set(null); if (session.isConnected() && session.isOpen()) { session.disconnect(); } } catch (HibernateException ex) { throw new InfrastructureException(ex); } return session; }