net.sf.gilead.core
Interface IPersistenceUtil

All Known Implementing Classes:
HibernateJBossUtil, HibernateJpaUtil, HibernateSpringUtil, HibernateUtil

public interface IPersistenceUtil

Interface for all Facade over (JPA) persistence engines. It allows the library to work with Hibernate and (soon) OpenJPA and EclipseLink

Author:
bruno.marchesson

Method Summary
 void closeCurrentSession()
          Close the session opened with 'openSession' call
 java.lang.Object createEntityProxy(java.util.Map<java.lang.String,java.io.Serializable> proxyInformations)
          Create an uninitialized proxy from the proxy informations
 java.lang.Object createPersistentCollection(java.util.Map<java.lang.String,java.io.Serializable> proxyInformations, java.lang.Object underlyingCollection)
          Create a persistent collection from serialized informations
 java.io.Serializable getId(java.lang.Object pojo)
           
 java.io.Serializable getId(java.lang.Object pojo, java.lang.Class<?> persistentClass)
           
 java.lang.Class<?> getUnenhancedClass(java.lang.Class<?> clazz)
          Get the persistent class without proxy
 void initialize(java.lang.Object proxy)
          Initialize the argument if not
 boolean isEnhanced(java.lang.Class<?> clazz)
          Indicated if the argument class is enhanced or not
 boolean isInitialized(java.lang.Object proxy)
          Indicates it the argument is initialized not
 boolean isPersistentClass(java.lang.Class<?> clazz)
          Indicates if the class is managed by the persistance container of not
 boolean isPersistentCollection(java.lang.Class<?> collectionClass)
          Indicates if the argument collection is persistent or not
 boolean isPersistentPojo(java.lang.Object pojo)
          Indicates if the pojo is persistent 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
 java.util.Map<java.lang.String,java.io.Serializable> serializeEntityProxy(java.lang.Object proxy)
          Serialize proxy informations of the argument entity into a map of properties
 java.util.Map<java.lang.String,java.io.Serializable> serializePersistentCollection(java.lang.Object persistentCollection)
          Serialize a persistent collection
 

Method Detail

openSession

void openSession()
Open a new session


closeCurrentSession

void closeCurrentSession()
Close the session opened with 'openSession' call


load

java.lang.Object load(java.io.Serializable id,
                      java.lang.Class<?> persistentClass)
Load a fresh instance of the persistent Pojo

Parameters:
clonePojo - the clone pojo (needed for ID)
persistentClass - the persistent class
Returns:
the loaded instance

getId

java.io.Serializable getId(java.lang.Object pojo)
Returns:
the ID of the argument Hibernate Pojo

getId

java.io.Serializable getId(java.lang.Object pojo,
                           java.lang.Class<?> persistentClass)
Returns:
the ID of the argument DTO with the same name than the persistent class

isPersistentPojo

boolean isPersistentPojo(java.lang.Object pojo)
Indicates if the pojo is persistent or not. Its class must be declared as persistent and the pojo must have an ID


isPersistentClass

boolean isPersistentClass(java.lang.Class<?> clazz)
Indicates if the class is managed by the persistance container of not


getUnenhancedClass

java.lang.Class<?> getUnenhancedClass(java.lang.Class<?> clazz)
Get the persistent class without proxy

Returns:
the underlying persistent class

isEnhanced

boolean isEnhanced(java.lang.Class<?> clazz)
Indicated if the argument class is enhanced or not

Parameters:
clazz - the persistent class
Returns:
true is the class is enhanced, false otherwise

isPersistentCollection

boolean isPersistentCollection(java.lang.Class<?> collectionClass)
Indicates if the argument collection is persistent or not

Parameters:
collectionClass - the collection class
Returns:

isInitialized

boolean isInitialized(java.lang.Object proxy)
Indicates it the argument is initialized not

Parameters:
proxy - the instance to check
Returns:

initialize

void initialize(java.lang.Object proxy)
Initialize the argument if not

Parameters:
proxy - the instance to initialize

serializeEntityProxy

java.util.Map<java.lang.String,java.io.Serializable> serializeEntityProxy(java.lang.Object proxy)
Serialize proxy informations of the argument entity into a map of properties

Parameters:
proxy - the proxy to serialize
Returns:
a map of properties

createEntityProxy

java.lang.Object createEntityProxy(java.util.Map<java.lang.String,java.io.Serializable> proxyInformations)
Create an uninitialized proxy from the proxy informations

Parameters:
proxyInformations - the serialized proxy informations
Returns:
the generated proxy

serializePersistentCollection

java.util.Map<java.lang.String,java.io.Serializable> serializePersistentCollection(java.lang.Object persistentCollection)
Serialize a persistent collection

Parameters:
persistentCollection - the persistent collection
Returns:
a Map with mininmum informations needed to re-create the persistent info

createPersistentCollection

java.lang.Object createPersistentCollection(java.util.Map<java.lang.String,java.io.Serializable> proxyInformations,
                                            java.lang.Object underlyingCollection)
Create a persistent collection from serialized informations

Parameters:
serialized - form of the persistent collection informations
underlyingCollection - the filled underlying collection
Returns:
the created persistent collection