public abstract class POJOPersistenceProviderBase extends java.lang.Object implements IPersistenceProvider
Constructor and Description |
---|
POJOPersistenceProviderBase() |
Modifier and Type | Method and Description |
---|---|
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.
|
protected abstract java.lang.Object |
createQuery(java.lang.String query)
Creates a query, it can be Hibernate query or JPA query.
|
protected abstract java.lang.Object |
find(java.lang.Class pojoClass,
java.io.Serializable key)
Return the object associated to the sent key.
|
java.lang.Object |
find(MetaModel metaModel,
java.util.Map keyValues)
Find an object from its key in map format.
|
protected java.lang.Object |
find(MetaModel metaModel,
java.util.Map keyValues,
boolean useQueryForFind) |
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 keyValues)
Find an object by any property (or properties).
|
java.lang.Object |
findByKeyUsingQuery(MetaModel metaModel,
java.util.Map keyValues) |
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.lang.String |
getModelName(java.lang.Object modelObject)
Model name from the model object.
|
protected abstract java.lang.Object |
getUniqueResult(java.lang.Object query)
Returns the unique result of the sent query.
|
java.util.Map |
keyToMap(MetaModel metaModel,
java.lang.Object key)
Returns a map that contains the value of primary key sent as object.
|
void |
moveCollectionElement(MetaModel metaModel,
java.util.Map keyValues,
java.lang.String collectionName,
int from,
int to)
Move an element in a collection.
|
protected abstract void |
persist(java.lang.Object object)
Marks the object as persistent.
|
protected abstract void |
setParameterToQuery(java.lang.Object query,
java.lang.String name,
java.lang.Object value)
Sets the parameter to the indicated query.
|
IPropertiesContainer |
toPropertiesContainer(MetaModel metaModel,
java.lang.Object o)
Return an IPropertiesContainer to manage using introspection the sent object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
begin, commit, createTabProvider, flush, reassociate, refreshIfManaged, remove, rollback
protected abstract java.lang.Object find(java.lang.Class pojoClass, java.io.Serializable key)
protected abstract void persist(java.lang.Object object)
protected abstract java.lang.Object createQuery(java.lang.String query)
protected abstract void setParameterToQuery(java.lang.Object query, java.lang.String name, java.lang.Object value)
The query is of the type returned by createQuery
method.
protected abstract java.lang.Object getUniqueResult(java.lang.Object query)
It does not fail if there more than one match, in this case must returns
the first one.
query
- Of the type returned by createQuery
method.public java.lang.Object find(MetaModel metaModel, java.util.Map keyValues) throws javax.ejb.FinderException
IPersistenceProvider
find
in interface IPersistenceProvider
javax.ejb.FinderException
protected java.lang.Object find(MetaModel metaModel, java.util.Map keyValues, boolean useQueryForFind) throws javax.ejb.FinderException
javax.ejb.FinderException
public java.lang.Object find(MetaModel metaModel, java.lang.Object key) throws javax.ejb.FinderException
IPersistenceProvider
find
in interface IPersistenceProvider
javax.ejb.FinderException
public void moveCollectionElement(MetaModel metaModel, java.util.Map keyValues, java.lang.String collectionName, int from, int to) throws javax.ejb.FinderException, XavaException
IPersistenceProvider
The collection must be sortable, in JPA it means to be a List with @OrderColumn.
moveCollectionElement
in interface IPersistenceProvider
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.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.public IPropertiesContainer toPropertiesContainer(MetaModel metaModel, java.lang.Object o) throws XavaException
IPersistenceProvider
toPropertiesContainer
in interface IPersistenceProvider
XavaException
public java.lang.Object create(MetaModel metaModel, java.util.Map values) throws javax.ejb.CreateException, ValidationException, XavaException
IPersistenceProvider
create
in interface IPersistenceProvider
javax.ejb.CreateException
ValidationException
XavaException
public java.lang.Object getKey(MetaModel metaModel, java.util.Map keyValues) throws XavaException
IPersistenceProvider
For example, in EJB2 will be the Key class, in Hibernate can be the POJO class, and JPA ...
getKey
in interface IPersistenceProvider
XavaException
public java.lang.Object getContainer(MetaModel metaModel, java.util.Map containerKeyValues) throws XavaException
IPersistenceProvider
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.
getContainer
in interface IPersistenceProvider
XavaException
public java.util.Map keyToMap(MetaModel metaModel, java.lang.Object key) throws XavaException
IPersistenceProvider
The map must contain at least the primary key value, but it can contains more, the rest is ignored.
keyToMap
in interface IPersistenceProvider
XavaException
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
IPersistenceProvider
createAggregate
in interface IPersistenceProvider
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.javax.ejb.CreateException
ValidationException
java.rmi.RemoteException
XavaException
public java.lang.Object findByAnyProperty(MetaModel metaModel, java.util.Map keyValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException, XavaException
IPersistenceProvider
Returns the first object that match with the sent arguments (searchingValues
).
findByAnyProperty
in interface IPersistenceProvider
javax.ejb.ObjectNotFoundException
javax.ejb.FinderException
XavaException
public java.lang.Object findByKeyUsingQuery(MetaModel metaModel, java.util.Map keyValues) throws javax.ejb.ObjectNotFoundException, javax.ejb.FinderException, XavaException
javax.ejb.ObjectNotFoundException
javax.ejb.FinderException
XavaException
public java.lang.String getModelName(java.lang.Object modelObject)
IPersistenceProvider
getModelName
in interface IPersistenceProvider