org.zkoss.zkplus.hibernate
Class HibernateUtil

java.lang.Object
  extended by org.zkoss.zkplus.hibernate.HibernateUtil

public class HibernateUtil
extends java.lang.Object

Utitlity to access Hibernate Session. This implemenation works with the Hibernate's thread session context (version 3.1+). That is, you have to specified hibernate's configuration file "hibernate.cfg.xml" to as follows:


  <session-factory>
                ...
                <property name="current_session_context_class">thread</property>
  </session-factory>
 

 

Also notice that the zkplus.jar must be put under application's WEB-INF/lib because the SessionFactory is stored as a class static member.

Author:
henrichen

Constructor Summary
HibernateUtil()
           
 
Method Summary
static void closeSession()
          Wrapping HibernateUtil.getSessionFactory().getCurrentSession().close() into a simple API.
static org.hibernate.Session currentSession()
          Wrapping HibernateUtil.getSessionFactory().getCurrentSession() into a simple API.
static org.hibernate.SessionFactory getSessionFactory()
          Get the singleton hibernate Session Factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateUtil

public HibernateUtil()
Method Detail

getSessionFactory

public static org.hibernate.SessionFactory getSessionFactory()
Get the singleton hibernate Session Factory.


currentSession

public static org.hibernate.Session currentSession()
                                            throws org.hibernate.HibernateException
Wrapping HibernateUtil.getSessionFactory().getCurrentSession() into a simple API.

Throws:
org.hibernate.HibernateException

closeSession

public static void closeSession()
                         throws org.hibernate.HibernateException
Wrapping HibernateUtil.getSessionFactory().getCurrentSession().close() into a simple API.

Throws:
org.hibernate.HibernateException


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.