|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.zkplus.hibernate.HibernateUtil
public class HibernateUtil
Utility to access Hibernate Session. This implementation 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>
Since ZK 3.0.1, if your hibernate configuration file name is not the default "hibernate.cfg.xml", you can specify it in WEB-INF/zk.xml. Just add following lines:
<preference> <name>HibernateUtil.config</name> <value>YOUR-HIBERNATE-FILENAME</value>
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.
Applicable to Hibernate version 3.2.ga or later
Field Summary | |
---|---|
static java.lang.String |
CONFIG
Deprecated. A preference or a library property used to configure HibernateUtil . |
Constructor Summary | |
---|---|
HibernateUtil()
Deprecated. |
Method Summary | |
---|---|
static void |
closeSession()
Deprecated. Wrapping HibernateUtil.getSessionFactory().getCurrentSession().close() into a simple API. |
static org.hibernate.Session |
currentSession()
Deprecated. Wrapping HibernateUtil.getSessionFactory().getCurrentSession() into a simple API. |
static org.hibernate.SessionFactory |
getSessionFactory()
Deprecated. Get the singleton hibernate Session Factory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CONFIG
HibernateUtil
.
It first looks up Configuration.getPreference(java.lang.String, java.lang.String)
, and then
Library.getProperty(java.lang.String)
. Ignored if none of them is specified.
Constructor Detail |
---|
public HibernateUtil()
Method Detail |
---|
public static org.hibernate.SessionFactory getSessionFactory()
public static org.hibernate.Session currentSession() throws org.hibernate.HibernateException
org.hibernate.HibernateException
public static void closeSession() throws org.hibernate.HibernateException
org.hibernate.HibernateException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |