org.openxava.model.impl
Class HibernatePersistenceProvider

java.lang.Object
  extended by org.openxava.model.impl.POJOPersistenceProviderBase
      extended by org.openxava.model.impl.HibernatePersistenceProvider
All Implemented Interfaces:
IPersistenceProvider

public class HibernatePersistenceProvider
extends POJOPersistenceProviderBase

Author:
M� Carmen Gimeno Alabau

Constructor Summary
HibernatePersistenceProvider()
           
 
Method Summary
 void begin()
          Mark the starting of the unit of work associated to this thread.
 void commit()
          Commit the work made by this persistent provider.
protected  java.lang.Object createQuery(java.lang.String query)
          Creates a query, it can be Hibernate query or JPA query.
 ITabProvider createTabProvider()
          Provides tabular data.
protected  java.lang.Object find(java.lang.Class pojoClass, java.io.Serializable key)
          Return the object associated to the sent key.
 void flush()
          Save in database all persistent data still in memory.
protected  java.lang.Object getUniqueResult(java.lang.Object query)
          Returns the unique result of the sent query.
protected  void persist(java.lang.Object object)
          Marks the object as persistent.
 void reassociate(java.lang.Object entity)
          Reassociates a detached object to its persistent storage.
 void refreshIfManaged(java.lang.Object object)
          Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
 void remove(MetaModel metaModel, java.util.Map keyValues)
          Remove the object from persistent storage.
 void rollback()
          Rollback the work made by this persistent provider.
protected  void setParameterToQuery(java.lang.Object query, java.lang.String name, java.lang.Object value)
          Sets the parameter to the indicated query.
 
Methods inherited from class org.openxava.model.impl.POJOPersistenceProviderBase
create, createAggregate, find, find, find, findByAnyProperty, findByKeyUsingQuery, getContainer, getKey, keyToMap, toPropertiesContainer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernatePersistenceProvider

public HibernatePersistenceProvider()
Method Detail

find

protected java.lang.Object find(java.lang.Class pojoClass,
                                java.io.Serializable key)
Description copied from class: POJOPersistenceProviderBase
Return the object associated to the sent key.

Specified by:
find in class POJOPersistenceProviderBase

persist

protected void persist(java.lang.Object object)
Description copied from class: POJOPersistenceProviderBase
Marks the object as persistent.

Specified by:
persist in class POJOPersistenceProviderBase

remove

public void remove(MetaModel metaModel,
                   java.util.Map keyValues)
            throws RemoveException,
                   XavaException
Description copied from interface: IPersistenceProvider
Remove the object from persistent storage.

Throws:
RemoveException
XavaException

begin

public void begin()
Description copied from interface: IPersistenceProvider
Mark the starting of the unit of work associated to this thread.

This method may be empty (for example in case of using CMT).


commit

public void commit()
Description copied from interface: IPersistenceProvider
Commit the work made by this persistent provider.

This method may be empty (for example in case of using CMT).


rollback

public void rollback()
Description copied from interface: IPersistenceProvider
Rollback the work made by this persistent provider.

This method may be empty (for example in case of using CMT).


reassociate

public void reassociate(java.lang.Object entity)
Description copied from interface: IPersistenceProvider
Reassociates a detached object to its persistent storage.

This is for use when an object is serialized using RMI/IIOP, and need to reassociato to its persistent storage.
This method may be empty, because in some technologies has no sense.


flush

public void flush()
Description copied from interface: IPersistenceProvider
Save in database all persistent data still in memory.

This method may be empty, because in some technologies has no sense.


createQuery

protected java.lang.Object createQuery(java.lang.String query)
Description copied from class: POJOPersistenceProviderBase
Creates a query, it can be Hibernate query or JPA query.

Specified by:
createQuery in class POJOPersistenceProviderBase

setParameterToQuery

protected void setParameterToQuery(java.lang.Object query,
                                   java.lang.String name,
                                   java.lang.Object value)
Description copied from class: POJOPersistenceProviderBase
Sets the parameter to the indicated query.

The query is of the type returned by createQuery method.

Specified by:
setParameterToQuery in class POJOPersistenceProviderBase

getUniqueResult

protected java.lang.Object getUniqueResult(java.lang.Object query)
Description copied from class: POJOPersistenceProviderBase
Returns the unique result of the sent query.

It does not fail if there more than one match, in this case must returns the first one.

Specified by:
getUniqueResult in class POJOPersistenceProviderBase
Parameters:
query - Of the type returned by createQuery method.
Returns:
Null if not result.

refreshIfManaged

public void refreshIfManaged(java.lang.Object object)
Description copied from interface: IPersistenceProvider
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.

If the object is null or it's not managed simply do nothing, but not fails.
This method may be empty, because in some technologies has no sense.


createTabProvider

public ITabProvider createTabProvider()
Description copied from interface: IPersistenceProvider
Provides tabular data.