Code example for SessionFactory

Methods: openSession

0
    } 
	 
	public static Session getSession() {
		Session s = HibernateUtil.sessionThreadLocal.get();
		if (s == null) {
			s = HibernateUtil.sessionFactory.openSession();            
			HibernateUtil.sessionThreadLocal.set(s);
		}  
		return s;
	} 
	 
	public static void closeSession() throws HibernateException {
		Session s = HibernateUtil.sessionThreadLocal.get();
		HibernateUtil.sessionThreadLocal.set(null);
		if (s != null && s.isOpen()) s.close();
	} 
	 
	public static void beginTransaction() throws HibernateException {
		try { 
			Transaction t = transactionThreadLocal.get();