Class POJOPersistenceProviderBase
java.lang.Object
org.openxava.model.impl.POJOPersistenceProviderBase
- All Implemented Interfaces:
Serializable, IPersistenceProvider
- Direct Known Subclasses:
JPAPersistenceProvider
Abstract class for create Persistence Providers based in POJOs.
- Author:
- Javier Paniza
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate 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.protected abstract ObjectcreateQuery(String query) Creates a query, it can be Hibernate query or JPA query.protected abstract Objectfind(Class pojoClass, Serializable key) Return the object associated to the sent key.Find a object from its key object.Find an object from its key in map format.protected ObjectfindByAnyProperty(MetaModel metaModel, Map keyValues) Find an object by any property (or properties).findByKeyUsingQuery(MetaModel metaModel, Map keyValues) 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.protected abstract ObjectgetUniqueResult(Object query) Returns the unique result of the sent query.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.protected abstract voidMarks the object as persistent.protected abstract voidsetParameterToQuery(Object query, String name, Object value) Sets the parameter to the indicated query.toPropertiesContainer(MetaModel metaModel, Object o) Return an IPropertiesContainer to manage using introspection the sent object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IPersistenceProvider
begin, commit, createTabProvider, flush, reassociate, refreshIfManaged, remove, rollback
-
Constructor Details
-
POJOPersistenceProviderBase
public POJOPersistenceProviderBase()
-
-
Method Details
-
find
Return the object associated to the sent key. -
persist
Marks the object as persistent. -
createQuery
-
setParameterToQuery
-
getUniqueResult
-
find
Description copied from interface:IPersistenceProviderFind an object from its key in map format.- Specified by:
findin interfaceIPersistenceProvider- Returns:
- Never null.
- Throws:
javax.ejb.FinderException
-
find
-
find
Description copied from interface:IPersistenceProviderFind a object from its key object.- Specified by:
findin interfaceIPersistenceProvider- Returns:
- Never null.
- Throws:
javax.ejb.FinderException
-
moveCollectionElement
public void moveCollectionElement(MetaModel metaModel, Map keyValues, 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.FinderException- Logic problem on find.XavaException- Any problem related to OpenXava. Rollback transaction.
-
toPropertiesContainer
public IPropertiesContainer toPropertiesContainer(MetaModel metaModel, Object o) throws XavaException Description copied from interface:IPersistenceProviderReturn an IPropertiesContainer to manage using introspection the sent object.- Specified by:
toPropertiesContainerin interfaceIPersistenceProvider- Throws:
XavaException
-
create
public Object create(MetaModel metaModel, Map values) throws 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.CreateExceptionValidationExceptionXavaException
-
getKey
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
-
getContainer
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
-
keyToMap
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
-
createAggregate
public Object createAggregate(MetaModel metaModel, Map values, MetaModel metaModelContainer, Object containerModel, int number) throws javax.ejb.CreateException, ValidationException, 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.CreateExceptionValidationExceptionRemoteExceptionXavaException
-
findByAnyProperty
public Object findByAnyProperty(MetaModel metaModel, Map keyValues) 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
-
findByKeyUsingQuery
public Object findByKeyUsingQuery(MetaModel metaModel, Map keyValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException, XavaException - Throws:
javax.ejb.ObjectNotFoundExceptionjavax.ejb.FinderExceptionXavaException
-
getModelName
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- Since:
- 5.6
-