net.sf.hibernate4gwt.core.hibernate
Class HibernateUtil

java.lang.Object
  extended by net.sf.hibernate4gwt.core.hibernate.HibernateUtil
All Implemented Interfaces:
IPersistenceUtil

public class HibernateUtil
extends java.lang.Object
implements IPersistenceUtil

Persistent helper for Hibernate implementation Centralizes the SessionFactory and add some needed methods. Not really a singleton, since there can be as many HibernateUtil instance as different sessionFactories

Author:
BMARCHESSON

Constructor Summary
HibernateUtil()
          Default constructor
 
Method Summary
 void closeCurrentSession()
          Open a new session
 java.io.Serializable getId(java.lang.Object pojo)
           
 java.io.Serializable getId(java.lang.Object pojo, java.lang.Class<?> hibernateClass)
           
static HibernateUtil getInstance()
           
 java.lang.Class<?> getPersistentClass(java.lang.Class<?> clazz)
           
 SessionFactory getSessionFactory()
           
 void initializeProxy(java.lang.Object proxy)
          Initialize the argument proxy
 boolean isEnhanced(java.lang.Class<?> clazz)
          Indicated if the argument class is enhanced or not
 boolean isPersistentClass(java.lang.Class<?> clazz)
          Indicates if the class is managed by the persistence container of not
 boolean isPersistentCollection(java.lang.Class<?> collectionClass)
          Indicates if the collection class is managed by the persistence container of not
 boolean isPersistentPojo(java.lang.Object pojo)
          Indicates if the pojo is persistent or not
 boolean isProxy(java.lang.Object proxy)
          Indicates it the argument is a proxy or not
 java.lang.Object load(java.io.Serializable id, java.lang.Class<?> persistentClass)
          Load a fresh instance of the persistent Pojo
 void openSession()
          Open a new session
 void setSessionFactory(SessionFactory sessionFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateUtil

public HibernateUtil()
Default constructor

Method Detail

getInstance

public static HibernateUtil getInstance()
Returns:
the unique instance of the singleton

getSessionFactory

public SessionFactory getSessionFactory()
Returns:
the hibernate session Factory

setSessionFactory

public void setSessionFactory(SessionFactory sessionFactory)
Parameters:
sessionFactory - the factory to set

getId

public java.io.Serializable getId(java.lang.Object pojo)
Specified by:
getId in interface IPersistenceUtil
Returns:
the ID of the argument Hibernate Pojo

getId

public java.io.Serializable getId(java.lang.Object pojo,
                                  java.lang.Class<?> hibernateClass)
Specified by:
getId in interface IPersistenceUtil
Returns:
the ID of the argument DTO with the same name than the persistent class

isPersistentPojo

public boolean isPersistentPojo(java.lang.Object pojo)
Description copied from interface: IPersistenceUtil
Indicates if the pojo is persistent or not

Specified by:
isPersistentPojo in interface IPersistenceUtil

isPersistentClass

public boolean isPersistentClass(java.lang.Class<?> clazz)
Description copied from interface: IPersistenceUtil
Indicates if the class is managed by the persistence container of not

Specified by:
isPersistentClass in interface IPersistenceUtil

isPersistentCollection

public boolean isPersistentCollection(java.lang.Class<?> collectionClass)
Description copied from interface: IPersistenceUtil
Indicates if the collection class is managed by the persistence container of not

Specified by:
isPersistentCollection in interface IPersistenceUtil

getPersistentClass

public java.lang.Class<?> getPersistentClass(java.lang.Class<?> clazz)
Specified by:
getPersistentClass in interface IPersistenceUtil
Returns:
the underlying persistent class

isEnhanced

public boolean isEnhanced(java.lang.Class<?> clazz)
Description copied from interface: IPersistenceUtil
Indicated if the argument class is enhanced or not

Specified by:
isEnhanced in interface IPersistenceUtil
Parameters:
clazz - the persistent class
Returns:
true is the class is enhanced, false otherwise

openSession

public void openSession()
Description copied from interface: IPersistenceUtil
Open a new session

Specified by:
openSession in interface IPersistenceUtil

closeCurrentSession

public void closeCurrentSession()
Description copied from interface: IPersistenceUtil
Open a new session

Specified by:
closeCurrentSession in interface IPersistenceUtil

load

public java.lang.Object load(java.io.Serializable id,
                             java.lang.Class<?> persistentClass)
Description copied from interface: IPersistenceUtil
Load a fresh instance of the persistent Pojo

Specified by:
load in interface IPersistenceUtil
persistentClass - the persistent class
Returns:
the loaded instance

isProxy

public boolean isProxy(java.lang.Object proxy)
Description copied from interface: IPersistenceUtil
Indicates it the argument is a proxy or not

Specified by:
isProxy in interface IPersistenceUtil
Returns:

initializeProxy

public void initializeProxy(java.lang.Object proxy)
Description copied from interface: IPersistenceUtil
Initialize the argument proxy

Specified by:
initializeProxy in interface IPersistenceUtil