org.openxava.model.impl
Interface IPersistenceProvider

All Known Implementing Classes:
EJBPersistenceProvider, HibernatePersistenceProvider, JPAPersistenceProvider, POJOPersistenceProviderBase

public interface IPersistenceProvider

Provides the implementation of the persistence services used in MapFacadeBean.

For all methods you can use any RuntimeException as system exception (this exception always abort the operation and rollback the transaction). You can use PersistenceProviderException as RuntimeException, but this is not mandatory. You can throw PersistenceException, JDOException, HibernateException, EJBException or whatever RuntimeException your want.

Author:
MĒ Carmen Gimeno Alabau

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.
 java.lang.Object create(MetaModel metaModel, java.util.Map values)
          Create a persistent object (saved in database) from the data passed in map format.
 java.lang.Object createAggregate(MetaModel metaModel, java.util.Map values, MetaModel metaModelContainer, java.lang.Object containerModel, int number)
          Create an aggregate (saving it in database) from the data passed in map format.
 java.lang.Object find(MetaModel metaModel, java.util.Map keyValues)
          Find an object from its key in map format.
 java.lang.Object find(MetaModel metaModel, java.lang.Object key)
          Find a object from its key object.
 java.lang.Object findByAnyProperty(MetaModel metaModel, java.util.Map searchingValues)
          Find an object by any property (or properties).
 void flush()
          Save in database all persistent data still in memory.
 java.lang.Object getContainer(MetaModel metaModel, java.util.Map containerKeyValues)
          Return the object that represents the container object.
 java.lang.Object getKey(MetaModel metaModel, java.util.Map keyValues)
          Return an object that can be used as primary key in model layer.
 java.util.Map keyToMap(MetaModel metaModel, java.lang.Object key)
          Returns a map that contains the value of primary key sent as object.
 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.
 IPropertiesContainer toPropertiesContainer(MetaModel metaModel, java.lang.Object modelObject)
          Return an IPropertiesContainer to manage using introspection the sent object.
 

Method Detail

findByAnyProperty

java.lang.Object findByAnyProperty(MetaModel metaModel,
                                   java.util.Map searchingValues)
                                   throws ObjectNotFoundException,
                                          FinderException,
                                          XavaException
Find an object by any property (or properties).

Returns the first object that match with the sent arguments (searchingValues).

Returns:
Never null.
Throws:
ObjectNotFoundException
FinderException
XavaException

find

java.lang.Object find(MetaModel metaModel,
                      java.util.Map keyValues)
                      throws ObjectNotFoundException,
                             FinderException,
                             XavaException
Find an object from its key in map format.

Returns:
Never null.
Throws:
ObjectNotFoundException
FinderException
XavaException

find

java.lang.Object find(MetaModel metaModel,
                      java.lang.Object key)
                      throws ObjectNotFoundException,
                             FinderException
Find a object from its key object.

Returns:
Never null.
Throws:
ObjectNotFoundException
FinderException

toPropertiesContainer

IPropertiesContainer toPropertiesContainer(MetaModel metaModel,
                                           java.lang.Object modelObject)
                                           throws XavaException
Return an IPropertiesContainer to manage using introspection the sent object.

Throws:
XavaException

create

java.lang.Object create(MetaModel metaModel,
                        java.util.Map values)
                        throws DuplicateKeyException,
                               CreateException,
                               ValidationException,
                               XavaException
Create a persistent object (saved in database) from the data passed in map format.

Throws:
DuplicateKeyException
CreateException
ValidationException
XavaException

createAggregate

java.lang.Object createAggregate(MetaModel metaModel,
                                 java.util.Map values,
                                 MetaModel metaModelContainer,
                                 java.lang.Object containerModel,
                                 int number)
                                 throws CreateException,
                                        ValidationException,
                                        java.rmi.RemoteException,
                                        XavaException
Create an aggregate (saving it in database) from the data passed in map format.

Parameters:
metaModel - of the aggregate to create.
values - Values to fill aggregate before save.
metaModelContainer - of model that will contain the aggregate.
containerModel - The object that will contain the new aggregate.
number - This number will be passed to calculator of type IAggregateOidCalculator, it can use this number to calculate the oid. It's a simple counter.
Throws:
CreateException
ValidationException
java.rmi.RemoteException
XavaException

getKey

java.lang.Object getKey(MetaModel metaModel,
                        java.util.Map keyValues)
                        throws XavaException
Return an object that can be used as primary key in model layer.

For example, in EJB2 will be the Key class, in Hibernate can be the POJO class, and JPA ...

Throws:
XavaException

keyToMap

java.util.Map keyToMap(MetaModel metaModel,
                       java.lang.Object key)
                       throws XavaException
Returns a map that contains the value of primary key sent as object.

The map must contain at least the primary key value, but it can contains more, the rest is ignored.

Throws:
XavaException

remove

void remove(MetaModel metaModel,
            java.util.Map keyValues)
            throws RemoveException,
                   XavaException
Remove the object from persistent storage.

Throws:
RemoveException
XavaException

begin

void begin()
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

void commit()
Commit the work made by this persistent provider.

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


rollback

void rollback()
Rollback the work made by this persistent provider.

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


flush

void flush()
Save in database all persistent data still in memory.

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


reassociate

void reassociate(java.lang.Object entity)
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.


getContainer

java.lang.Object getContainer(MetaModel metaModel,
                              java.util.Map containerKeyValues)
                              throws XavaException
Return the object that represents the container object.

The container object apply only to aggregates, and it's the object that containt to the aggregate. It can be a POJO or key class, depends on the implementation.

Throws:
XavaException

refreshIfManaged

void refreshIfManaged(java.lang.Object object)
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.