Class TransientPersistenceProvider
- java.lang.Object
-
- org.openxava.model.impl.TransientPersistenceProvider
-
- All Implemented Interfaces:
java.io.Serializable,IPersistenceProvider
public class TransientPersistenceProvider extends java.lang.Object implements IPersistenceProvider
- Since:
- 5.9.1
- Author:
- Javier Paniza
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TransientPersistenceProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()Mark the starting of the unit of work associated to this thread.voidcommit()Commit the work made by this persistent provider.java.lang.Objectcreate(MetaModel metaModel, java.util.Map values)Create a persistent object (saved in database) from the data passed in map format.java.lang.ObjectcreateAggregate(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.ITabProvidercreateTabProvider()Provides tabular data.java.lang.Objectfind(MetaModel metaModel, java.lang.Object key)Find a object from its key object.java.lang.Objectfind(MetaModel metaModel, java.util.Map keyValues)Find an object from its key in map format.java.lang.ObjectfindByAnyProperty(MetaModel metaModel, java.util.Map searchingValues)Find an object by any property (or properties).voidflush()Save in database all persistent data still in memory.java.lang.ObjectgetContainer(MetaModel metaModel, java.util.Map containerKeyValues)Return the object that represents the container object.static TransientPersistenceProvidergetInstance()java.lang.ObjectgetKey(MetaModel metaModel, java.util.Map keyValues)Return an object that can be used as primary key in model layer.java.lang.StringgetModelName(java.lang.Object modelObject)Model name from the model object.java.util.MapkeyToMap(MetaModel metaModel, java.lang.Object key)Returns a map that contains the value of primary key sent as object.voidmoveCollectionElement(MetaModel metaModel, java.util.Map keyValues, java.lang.String collectionName, int from, int to)Move an element in a collection.voidreassociate(java.lang.Object entity)Reassociates a detached object to its persistent storage.voidrefreshIfManaged(java.lang.Object object)Refresh the state of the instance from the database, overwriting changes made to the entity, if any.voidremove(MetaModel metaModel, java.util.Map keyValues)Remove the object from persistent storage.voidrollback()Rollback the work made by this persistent provider.IPropertiesContainertoPropertiesContainer(MetaModel metaModel, java.lang.Object modelObject)Return an IPropertiesContainer to manage using introspection the sent object.
-
-
-
Method Detail
-
getInstance
public static TransientPersistenceProvider getInstance()
-
findByAnyProperty
public java.lang.Object findByAnyProperty(MetaModel metaModel, java.util.Map searchingValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException, XavaException
Description copied from interface:IPersistenceProviderFind an object by any property (or properties).Returns the first object that match with the sent arguments (
searchingValues).- Specified by:
findByAnyPropertyin interfaceIPersistenceProvider- Returns:
- Never null.
- Throws:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderExceptionXavaException
-
find
public java.lang.Object find(MetaModel metaModel, java.util.Map keyValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException, XavaException
Description copied from interface:IPersistenceProviderFind an object from its key in map format.- Specified by:
findin interfaceIPersistenceProvider- Returns:
- Never null.
- Throws:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderExceptionXavaException
-
find
public java.lang.Object find(MetaModel metaModel, java.lang.Object key) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException
Description copied from interface:IPersistenceProviderFind a object from its key object.- Specified by:
findin interfaceIPersistenceProvider- Returns:
- Never null.
- Throws:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderException
-
toPropertiesContainer
public IPropertiesContainer toPropertiesContainer(MetaModel metaModel, java.lang.Object modelObject) throws XavaException
Description copied from interface:IPersistenceProviderReturn an IPropertiesContainer to manage using introspection the sent object.- Specified by:
toPropertiesContainerin interfaceIPersistenceProvider- Throws:
XavaException
-
create
public java.lang.Object create(MetaModel metaModel, java.util.Map values) throws javax.ejb.DuplicateKeyException, javax.ejb.CreateException, ValidationException, XavaException
Description copied from interface:IPersistenceProviderCreate a persistent object (saved in database) from the data passed in map format.- Specified by:
createin interfaceIPersistenceProvider- Throws:
javax.ejb.DuplicateKeyExceptionjavax.ejb.CreateExceptionValidationExceptionXavaException
-
moveCollectionElement
public void moveCollectionElement(MetaModel metaModel, java.util.Map keyValues, java.lang.String collectionName, int from, int to) throws javax.ejb.FinderException, XavaException
Description copied from interface:IPersistenceProviderMove an element in a collection.The collection must be sortable, in JPA it means to be a List with @OrderColumn.
- Specified by:
moveCollectionElementin interfaceIPersistenceProvider- 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.
-
createAggregate
public java.lang.Object createAggregate(MetaModel metaModel, java.util.Map values, MetaModel metaModelContainer, java.lang.Object containerModel, int number) throws javax.ejb.CreateException, ValidationException, java.rmi.RemoteException, XavaException
Description copied from interface:IPersistenceProviderCreate an aggregate (saving it in database) from the data passed in map format.- Specified by:
createAggregatein interfaceIPersistenceProvider- 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.CreateExceptionValidationExceptionjava.rmi.RemoteExceptionXavaException
-
getKey
public java.lang.Object getKey(MetaModel metaModel, java.util.Map keyValues) throws XavaException
Description copied from interface:IPersistenceProviderReturn 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 ...
- Specified by:
getKeyin interfaceIPersistenceProvider- Throws:
XavaException
-
keyToMap
public java.util.Map keyToMap(MetaModel metaModel, java.lang.Object key) throws XavaException
Description copied from interface:IPersistenceProviderReturns 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.
- Specified by:
keyToMapin interfaceIPersistenceProvider- Throws:
XavaException
-
remove
public void remove(MetaModel metaModel, java.util.Map keyValues) throws javax.ejb.RemoveException, XavaException
Description copied from interface:IPersistenceProviderRemove the object from persistent storage.- Specified by:
removein interfaceIPersistenceProvider- Throws:
javax.ejb.RemoveExceptionXavaException
-
begin
public void begin()
Description copied from interface:IPersistenceProviderMark the starting of the unit of work associated to this thread.This method may be empty (for example in case of using CMT).
- Specified by:
beginin interfaceIPersistenceProvider
-
commit
public void commit()
Description copied from interface:IPersistenceProviderCommit the work made by this persistent provider.This method may be empty (for example in case of using CMT).
- Specified by:
commitin interfaceIPersistenceProvider
-
rollback
public void rollback()
Description copied from interface:IPersistenceProviderRollback the work made by this persistent provider.This method may be empty (for example in case of using CMT).
- Specified by:
rollbackin interfaceIPersistenceProvider
-
flush
public void flush()
Description copied from interface:IPersistenceProviderSave in database all persistent data still in memory.This method may be empty, because in some technologies has no sense.
- Specified by:
flushin interfaceIPersistenceProvider
-
reassociate
public void reassociate(java.lang.Object entity)
Description copied from interface:IPersistenceProviderReassociates 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.- Specified by:
reassociatein interfaceIPersistenceProvider
-
getContainer
public java.lang.Object getContainer(MetaModel metaModel, java.util.Map containerKeyValues) throws XavaException
Description copied from interface:IPersistenceProviderReturn 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.
- Specified by:
getContainerin interfaceIPersistenceProvider- Throws:
XavaException
-
refreshIfManaged
public void refreshIfManaged(java.lang.Object object)
Description copied from interface:IPersistenceProviderRefresh 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.- Specified by:
refreshIfManagedin interfaceIPersistenceProvider
-
createTabProvider
public ITabProvider createTabProvider()
Description copied from interface:IPersistenceProviderProvides tabular data.- Specified by:
createTabProviderin interfaceIPersistenceProvider
-
getModelName
public java.lang.String getModelName(java.lang.Object modelObject)
Description copied from interface:IPersistenceProviderModel 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.- Specified by:
getModelNamein interfaceIPersistenceProvider
-
-