Interface IPersistenceProvider
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
IExplicitModifyPersistenceProvider
- All Known Implementing Classes:
JPAPersistenceProvider,POJOPersistenceProviderBase,TransientPersistenceProvider
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
Modifier and TypeMethodDescriptionvoidbegin()Mark the starting of the unit of work associated to this thread.voidcommit()Commit the work made by this persistent provider.Create a persistent object (saved in database) from the data passed in map format.createAggregate(MetaModel metaModel, Map values, MetaModel metaModelContainer, Object containerModel, int number) Create an aggregate (saving it in database) from the data passed in map format.Provides tabular data.Find a object from its key object.Find an object from its key in map format.findByAnyProperty(MetaModel metaModel, Map searchingValues) Find an object by any property (or properties).voidflush()Save in database all persistent data still in memory.getContainer(MetaModel metaModel, Map containerKeyValues) Return the object that represents the container object.Return an object that can be used as primary key in model layer.getModelName(Object modelObject) Model name from the model object.Returns a map that contains the value of primary key sent as object.voidmoveCollectionElement(MetaModel metaModel, Map keyValues, String collectionName, int from, int to) Move an element in a collection.voidreassociate(Object entity) Reassociates a detached object to its persistent storage.voidrefreshIfManaged(Object object) Refresh the state of the instance from the database, overwriting changes made to the entity, if any.voidRemove the object from persistent storage.voidrollback()Rollback the work made by this persistent provider.toPropertiesContainer(MetaModel metaModel, Object modelObject) Return an IPropertiesContainer to manage using introspection the sent object.
-
Method Details
-
findByAnyProperty
Object findByAnyProperty(MetaModel metaModel, Map searchingValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.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:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderExceptionXavaException
-
find
Object find(MetaModel metaModel, Map keyValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException, XavaException Find an object from its key in map format.- Returns:
- Never null.
- Throws:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderExceptionXavaException
-
find
Object find(MetaModel metaModel, Object key) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException Find a object from its key object.- Returns:
- Never null.
- Throws:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderException
-
toPropertiesContainer
IPropertiesContainer toPropertiesContainer(MetaModel metaModel, Object modelObject) throws XavaException Return an IPropertiesContainer to manage using introspection the sent object.- Throws:
XavaException
-
create
Object create(MetaModel metaModel, Map values) throws javax.ejb.DuplicateKeyException, javax.ejb.CreateException, ValidationException, XavaException Create a persistent object (saved in database) from the data passed in map format.- Throws:
javax.ejb.DuplicateKeyExceptionjavax.ejb.CreateExceptionValidationExceptionXavaException
-
moveCollectionElement
void moveCollectionElement(MetaModel metaModel, Map keyValues, String collectionName, int from, int to) throws javax.ejb.FinderException, XavaException Move an element in a collection.The collection must be sortable, in JPA it means to be a List with @OrderColumn.
- Parameters:
metaModel- of the entity that contains the collection. Not null.keyValues- Key value of the container of the collection. Not null.collectionName- Collection name of the container collection of element to move. Not null.from- Original position of the element in the collection. Zero based.to- Position in the collection where the element will be moved. Zero based.- Throws:
javax.ejb.ObjectNotFoundException- If object with this key does not existjavax.ejb.FinderException- Logic problem on find.XavaException- Any problem related to OpenXava. Rollback transaction.- Since:
- 5.6.1
-
createAggregate
Object createAggregate(MetaModel metaModel, Map values, MetaModel metaModelContainer, Object containerModel, int number) throws javax.ejb.CreateException, ValidationException, 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:
javax.ejb.CreateExceptionValidationExceptionRemoteExceptionXavaException
-
getKey
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
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
Remove the object from persistent storage.- Throws:
javax.ejb.RemoveExceptionXavaException
-
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
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
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
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
ITabProvider createTabProvider()Provides tabular data. -
getModelName
Model name from the model object. It can be null. This value is useful when inheritance is used and the official model name does not match the real model name, so if inheritance does not apply it can be null.- Since:
- 5.6
-