org.norther.tammi.root.db
Interface Persister

All Superinterfaces:
Cloneable
All Known Implementing Classes:
HibernatePersister, OJBPersister, PersisterAdapter

public interface Persister
extends Cloneable

An interface to classes providing access to the persistent layer.

Version:
$Id: Persister.java,v 1.72 2010-05-04 17:29:14 cvsimp Exp $
Author:
Marketta Priha

Nested Class Summary
static class Persister.Action
          The persistence actions.
static class Persister.Script
          The script type.
 
Method Summary
 boolean abortTransaction()
          Aborts a transaction to cancel updates to the repository.
 boolean beginTransaction()
          Begins a transaction to start updates in the repository.
<T> DBQuery<T>
buildQuery(Class<T> clazz, String expr, Persister.Script type)
          Builds a query to a query language expression for the specified class.
 DBQuery<Object[]> buildQuery(DBCriteria<?> criteria, String[] attributes, boolean distinct, Object... clazz)
          Builds a query to a specified criteria returning only selected attributes.
<T> DBQuery<T>
buildQuery(DBCriteria<T> criteria, boolean distinct, Object... clazz)
          Builds a query to a specified criteria.
<T> DBQuery<T>
buildQuery(Object sample, DBCriteria<?>... criteria)
          Builds a query to a sample object, an identity or a specific class.
<T> DBQuery<T>
buildQuery(String className, String expr, Persister.Script type)
          Builds a query to a query language expression for the named class.
 void clearCache()
          Clears the cache associated to this persister, if any.
 Object clone()
          Returns a clone.
 void close()
          Closes the connection to the repository.
 boolean commitTransaction()
          Commits a transaction to complete updates in the repository.
<T> DBCriteria<T>
createCriteria(Class<T> clazz)
          Creates implementation specific query criteria for the specified class.
<T> DBCriteria<T>
createCriteria(String className)
          Creates implementation specific query criteria for the named class.
 void deleteObject(Object object)
          Deletes an object from the repository.
 void deleteObjects(Class<?> clazz)
          Deletes objects of the specified class from the repository as one transaction.
 void deleteObjects(Class<?> clazz, String attribute, Object value, DBCriteria.Condition condition)
          Deletes objects of the specified class from the repository as one transaction.
 void deleteObjects(Collection<?> objects)
          Deletes a collection of objects from the repository as one transaction.
 void deleteObjects(DBCriteria<?> criteria, Object... clazz)
          Deletes objects of the specified criteria as one transaction.
 void deleteObjects(DBQuery<?> query)
          Deletes query objects from the repository as one transaction.
 void deleteObjects(String className)
          Deletes objects of the named class from the repository as one transaction.
 void deleteObjects(String className, String attribute, Object value, DBCriteria.Condition condition)
          Deletes objects of the named class from the repository as one transaction.
 void deleteReferences(Object object, String... classNames)
          Deletes an object and its dependencies from the repository.
 void dump(Collection<?> objects, File file)
          Dumps objects into a dump file if this persister supports files.
 void execute(String sql)
          Executes an SQL statement.
 void execute(String[] sql)
          Executes SQL statements as a batch.
 boolean exists(Object object)
          Checks whether an object exists in the repository.
 void exportReferences(Object source, Object target, boolean foreign, AttributeFilter... filter)
          Exports references from a source object to a target object.
 Object getAttributeValue(Object object, String field)
          Gets the reflected attribute value of the specified object.
 Object[] getAttributeValues(Object object, String field)
          Gets the reflected attribute values of the specified object.
 String getConnectionAlias()
          Gets the connection alias bound to this persister.
 Object getGroupId()
          Gets the group id of this persister.
 String getIdentityAttribute(Object sample, String... classNames)
          Gets the identity attribute of the specified sample object.
 String[] getIdentityAttributes(Object sample, String... classNames)
          Gets the identity attributes of the specified sample object.
 Object getIdentityValue(Object object)
          Gets the identity attribute value of the specified object.
 Object[] getIdentityValues(Object object)
          Gets an array of identity attribute values of the specified object.
 Locale getLocale()
          Gets the locale of this persister.
 MBeanServer getMBeanServer()
          Gets the MBean server of this persister.
 Object getObject(Object object)
          Gets an object from the repository.
 String[] getPersistentAttributes(Object sample, String... classNames)
          Gets the persistent attributes of the specified sample object.
 String getPersistentColumn(Object sample, String attribute, String... classNames)
          Gets the persistent column of an attribute of the specified sample object.
 String getPersistentTable(Object sample, String... classNames)
          Gets the persistent table of the specified sample object.
 Object getPersister()
          Gets the implementation specific persister adaptee, if any.
 PersisterFactory getPersisterFactory()
          Gets the persister factory of this persister.
 Principal getPrincipal()
          Gets the principal of this persister.
 String getProviderAlias()
          Gets the persistence provider alias.
<T> T
getReferenceValue(Object object, String field)
          Gets the referenced object of the specified object.
<T> List<T>
getReferenceValues(Object object, String field)
          Gets a list of referenced objects of the specified object.
 String getRepository(String className)
          Gets the name of the repository of the named class.
 Object getRootGroupId()
          Gets the root group id of this persister.
 Object getUserId()
          Gets the user id of this persister.
 Object getValidatedValue(Object object, String field)
          Gets the validated attribute value of the specified object.
 void importReferences(Object source, Object target, boolean foreign, AttributeFilter... filter)
          Imports references from the specified source object to a target object.
 void insertObject(Object object)
          Inserts an object to the repository.
 void insertObjects(Collection<?> objects)
          Inserts a collection of objects to the repository as one transaction.
 void insertReferences(Object object, String... classNames)
          Inserts an object and its dependencies to the repository.
 boolean isClosed()
          Checks whether this persister is closed.
 boolean isInTransaction()
          Checks whether this persister is performing a transaction.
 boolean isPersistentAttribute(Object sample, String attribute, String... classNames)
          Checks whether an attribute of the specified sample object is persistent.
 boolean isPersistentClass(Object sample, String... classNames)
          Checks whether the class of the specified sample object is persistent.
 boolean isPersistentObject(Object object)
          Checks whether the specified object is persistent.
 boolean isRelationAttribute(Object sample, String attribute, String... classNames)
          Checks whether an attribute of the specified sample object is relative.
 boolean isTransactionsSupported()
          Checks whether this persister implementation supports transactions.
 Collection<?> load(File file)
          Loads objects from a dump file if this persister supports files.
 Object mergeObject(Object object, AttributeFilter... filter)
          Merges an object in the repository.
 Object mergeReferences(Object object, AttributeFilter filter, String... classNames)
          Merges an object and its dependencies to the repository by applying an attribute filter.
 Object mergeReferences(Object object, String... classNames)
          Merges an object and its dependencies to the repository.
 Object queryBySample(Object sample, DBCriteria<?>... criteria)
          Queries an object by its properties or identity.
 int queryCount(Class<?> clazz, Object... values)
          Queries the count of objects the specified class.
 int queryCount(Class<?> clazz, String attribute, Object value, DBCriteria.Condition condition)
          Queries the count of objects of the specified class.
 int queryCount(DBCriteria<?> criteria, Object... clazz)
          Queries the count of objects of the specified criteria.
 int queryCount(DBQuery<?> query)
          Queries the count of objects the given query would return.
 int queryCount(String className, Object... values)
          Queries the count of objects the named class.
 int queryCount(String className, String attribute, Object value, DBCriteria.Condition condition)
          Queries the count of objects of the named class.
<T> QueryIterator<T>
queryIterator(Class<T> clazz, Object... values)
          Queries an iterator to objects of the specified class.
<T> QueryIterator<T>
queryIterator(Class<T> clazz, String attribute, Object value, DBCriteria.Condition condition)
          Queries an iterator to a collection of objects of the specified class.
<T> QueryIterator<T>
queryIterator(DBCriteria<T> criteria, Object... clazz)
          Queries an iterator to a collection of objects of the specified criteria.
<T> QueryIterator<T>
queryIterator(DBQuery<T> query)
          Queries an iterator to a collection of objects.
<T> QueryIterator<T>
queryIterator(String className, Object... values)
          Queries an iterator to objects of the named class.
<T> QueryIterator<T>
queryIterator(String className, String attribute, Object value, DBCriteria.Condition condition)
          Queries an iterator to a collection of objects of the named class.
<T> T
queryObject(Class<T> clazz, Object... values)
          Queries an object of the specified class.
<T> T
queryObject(Class<T> clazz, String attribute, Object value)
          Queries an object of the specified class with the named attribute.
<T> T
queryObject(DBCriteria<T> criteria, Object... clazz)
          Queries an object of the specified criteria.
<T> T
queryObject(DBQuery<T> query)
          Queries an object.
<T> T
queryObject(String className, Object... values)
          Queries an object of the named class.
<T> T
queryObject(String className, String attribute, Object value)
          Queries an object of the named class with the named attribute.
<T> Collection<T>
queryObjects(Class<T> clazz)
          Queries objects of the specified class.
<T> Collection<T>
queryObjects(Class<T> clazz, String attribute, Object value, DBCriteria.Condition condition)
          Queries objects of the specified class.
<T> Collection<T>
queryObjects(DBCriteria<T> criteria, Object... clazz)
          Queries objects of the specified criteria.
<T> Collection<T>
queryObjects(DBQuery<T> query)
          Queries objects.
<T> Collection<T>
queryObjects(String className)
          Queries objects of the named class.
<T> Collection<T>
queryObjects(String className, String attribute, Object value, DBCriteria.Condition condition)
          Queries objects of the named class.
 boolean refreshLocators(Object object, String... classNames)
          Refreshes locators of the specified object.
 boolean refreshReference(Object object, String reference, String... classNames)
          Refreshes a named reference of the specified object.
 boolean refreshReferences(Object object, String... classNames)
          Refreshes references of the specified object.
 void removeFromCache(Object object)
          Removes the specified object from the cache.
 void resetIdentityValues(Object object)
          Resets identity attribute values of the specified object to nulls, if they are auto incremental.
 void retrieveReference(Object object, String reference, String... classNames)
          Retrieves a named reference of the specified object.
 void retrieveReferences(Object object, String... classNames)
          Retrieves references of the specified object.
 void setAttributeValue(Object object, String field, Object value)
          Sets the reflected attribute value of the specified object.
 void setIdentityValue(Object object, Object value)
          Sets the identity attribute value of the specified object.
 void setIdentityValues(Object object, Object[] values)
          Sets an array of identity attribute values of the specified object.
 void setLocale(Locale loc)
          Sets the locale of this persister.
 void setValidatedValue(Object object, String field, Object value)
          Sets the validated attribute value of the specified object.
 void storeObject(Object object)
          Stores an object to the repository.
 void storeObjects(Collection<?> objects)
          Stores a collection of objects to the repository as one transaction.
 void storeReferences(Object object, String... classNames)
          Stores an object and its dependencies to the repository.
 void updateObject(Object object)
          Updates an object in the repository.
 void updateObjects(Collection<?> objects)
          Updates a collection of objects in the repository as one transaction.
 void updateReferences(Object object, String... classNames)
          Updates an object and its dependencies to the repository.
 

Method Detail

clone

Object clone()
Returns a clone.

Returns:
a copy of this persister.

getPersister

Object getPersister()
Gets the implementation specific persister adaptee, if any.

Returns:
the adaptee or null.

getConnectionAlias

String getConnectionAlias()
Gets the connection alias bound to this persister.

Returns:
the connection alias.

getProviderAlias

String getProviderAlias()
Gets the persistence provider alias.

Returns:
the provider key.

close

void close()
Closes the connection to the repository. The persister should not be referred to after closing.


isClosed

boolean isClosed()
Checks whether this persister is closed.

Returns:
true if closed, otherwise false.

clearCache

void clearCache()
Clears the cache associated to this persister, if any.


removeFromCache

void removeFromCache(Object object)
Removes the specified object from the cache.

Parameters:
object - the object.

retrieveReferences

void retrieveReferences(Object object,
                        String... classNames)
Retrieves references of the specified object.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object.
classNames - dependent class names.

retrieveReference

void retrieveReference(Object object,
                       String reference,
                       String... classNames)
Retrieves a named reference of the specified object.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object.
reference - the reference attribute.
classNames - dependent class names.

refreshReferences

boolean refreshReferences(Object object,
                          String... classNames)
Refreshes references of the specified object.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object.
classNames - dependent class names.
Returns:
true if refreshed, false otherwise.

refreshReference

boolean refreshReference(Object object,
                         String reference,
                         String... classNames)
Refreshes a named reference of the specified object.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object.
reference - the reference attribute.
classNames - dependent class names.
Returns:
true if refreshed, false otherwise.

refreshLocators

boolean refreshLocators(Object object,
                        String... classNames)
Refreshes locators of the specified object.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object.
classNames - dependent class names.
Returns:
true if refreshed, false otherwise.

getIdentityAttribute

String getIdentityAttribute(Object sample,
                            String... classNames)
Gets the identity attribute of the specified sample object.

Parameters:
sample - the sample object.
classNames - the dependent class names.
Returns:
the identity attribute or null.

getIdentityAttributes

String[] getIdentityAttributes(Object sample,
                               String... classNames)
Gets the identity attributes of the specified sample object.

Parameters:
sample - the sample object.
classNames - the dependent class names.
Returns:
the identity attributes or null.

getPersistentAttributes

String[] getPersistentAttributes(Object sample,
                                 String... classNames)
Gets the persistent attributes of the specified sample object.

Parameters:
sample - the sample object.
classNames - the dependent class names.
Returns:
the attributes or null.

isPersistentClass

boolean isPersistentClass(Object sample,
                          String... classNames)
Checks whether the class of the specified sample object is persistent.

Parameters:
sample - the sample object.
classNames - the dependent class names.
Returns:
true for a persistent class, false otherwise.

isPersistentAttribute

boolean isPersistentAttribute(Object sample,
                              String attribute,
                              String... classNames)
Checks whether an attribute of the specified sample object is persistent.

Parameters:
sample - the sample object.
attribute - the field.
classNames - the dependent class names.
Returns:
true for a persistent attribute, false otherwise.

isRelationAttribute

boolean isRelationAttribute(Object sample,
                            String attribute,
                            String... classNames)
Checks whether an attribute of the specified sample object is relative.

Parameters:
sample - the sample object.
attribute - the field.
classNames - the dependent class names.
Returns:
true for a relation attribute, false otherwise.

getPersistentTable

String getPersistentTable(Object sample,
                          String... classNames)
Gets the persistent table of the specified sample object.

Parameters:
sample - the sample object.
classNames - the dependent class names.
Returns:
the persistent table or null.

getPersistentColumn

String getPersistentColumn(Object sample,
                           String attribute,
                           String... classNames)
Gets the persistent column of an attribute of the specified sample object.

Parameters:
sample - the sample object.
attribute - the field.
classNames - the dependent class names.
Returns:
the persistent column or null.

createCriteria

<T> DBCriteria<T> createCriteria(Class<T> clazz)
Creates implementation specific query criteria for the specified class.

Type Parameters:
T - the criteria type.
Parameters:
clazz - the class type.
Returns:
empty criteria.

createCriteria

<T> DBCriteria<T> createCriteria(String className)
Creates implementation specific query criteria for the named class.

Type Parameters:
T - the criteria type.
Parameters:
className - the class name.
Returns:
empty criteria.

buildQuery

<T> DBQuery<T> buildQuery(Object sample,
                          DBCriteria<?>... criteria)
Builds a query to a sample object, an identity or a specific class. The query type is on caller's response.

Type Parameters:
T - the query type.
Parameters:
sample - the sample, identity or class.
criteria - optional criteria.
Returns:
the corresponding query.

buildQuery

<T> DBQuery<T> buildQuery(Class<T> clazz,
                          String expr,
                          Persister.Script type)
Builds a query to a query language expression for the specified class.

Type Parameters:
T - the class type.
Parameters:
clazz - the class to query.
expr - the query expression.
type - the query type.
Returns:
the corresponding query.

buildQuery

<T> DBQuery<T> buildQuery(String className,
                          String expr,
                          Persister.Script type)
Builds a query to a query language expression for the named class.

Type Parameters:
T - the class type.
Parameters:
className - the class name to query.
expr - the query expression.
type - the query type.
Returns:
the corresponding query.

buildQuery

<T> DBQuery<T> buildQuery(DBCriteria<T> criteria,
                          boolean distinct,
                          Object... clazz)
Builds a query to a specified criteria.

Note that the signature must differ from that of a sample query to avoid conflicts.

Type Parameters:
T - the class type.
Parameters:
criteria - an implementation specific criteria.
distinct - true for a distinct query, false otherwise.
clazz - an alternate class or class name.
Returns:
the corresponding query.

buildQuery

DBQuery<Object[]> buildQuery(DBCriteria<?> criteria,
                             String[] attributes,
                             boolean distinct,
                             Object... clazz)
Builds a query to a specified criteria returning only selected attributes.

Parameters:
criteria - in implementation specific criteria.
attributes - the attributes to return.
distinct - true for a distinct query, false otherwise.
clazz - an alternate class or class name.
Returns:
the corresponding query.

queryBySample

Object queryBySample(Object sample,
                     DBCriteria<?>... criteria)
                     throws PersistenceException
Queries an object by its properties or identity.

Parameters:
sample - the sample, identity or class.
criteria - optional criteria.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObject

<T> T queryObject(DBQuery<T> query)
              throws PersistenceException
Queries an object. The specified query should identify only one unique object as implementations may throw an exception for multiple matches.

Type Parameters:
T - the query type.
Parameters:
query - the query.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObject

<T> T queryObject(DBCriteria<T> criteria,
                  Object... clazz)
              throws PersistenceException
Queries an object of the specified criteria.

Type Parameters:
T - the class type.
Parameters:
criteria - the criteria to apply.
clazz - an alternate class or class name.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObject

<T> T queryObject(Class<T> clazz,
                  Object... values)
              throws PersistenceException
Queries an object of the specified class.

Type Parameters:
T - the class type.
Parameters:
clazz - the class to query.
values - the PK(s) of the object.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObject

<T> T queryObject(String className,
                  Object... values)
              throws PersistenceException
Queries an object of the named class.

Type Parameters:
T - the class type.
Parameters:
className - the class name to query.
values - the PK(s) of the object.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObject

<T> T queryObject(Class<T> clazz,
                  String attribute,
                  Object value)
              throws PersistenceException
Queries an object of the specified class with the named attribute.

Type Parameters:
T - the class type.
Parameters:
clazz - the class to query.
attribute - the name of the attribute.
value - the value of the attribute.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObject

<T> T queryObject(String className,
                  String attribute,
                  Object value)
              throws PersistenceException
Queries an object of the named class with the named attribute.

Type Parameters:
T - the class type.
Parameters:
className - the class name to query.
attribute - the name of the attribute.
value - the value of the attribute.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

queryObjects

<T> Collection<T> queryObjects(Class<T> clazz)
                           throws PersistenceException
Queries objects of the specified class.

Type Parameters:
T - the class type.
Parameters:
clazz - the class to query.
Returns:
a collection of objects.
Throws:
PersistenceException - on errors.

queryObjects

<T> Collection<T> queryObjects(String className)
                           throws PersistenceException
Queries objects of the named class.

Type Parameters:
T - the class type.
Parameters:
className - the class name to query.
Returns:
a collection of objects.
Throws:
PersistenceException - on errors.

queryObjects

<T> Collection<T> queryObjects(DBQuery<T> query)
                           throws PersistenceException
Queries objects. All matchings objects are returned.

Type Parameters:
T - the query type.
Parameters:
query - the query.
Returns:
a collection of objects.
Throws:
PersistenceException - on errors.

queryObjects

<T> Collection<T> queryObjects(DBCriteria<T> criteria,
                               Object... clazz)
                           throws PersistenceException
Queries objects of the specified criteria.

Type Parameters:
T - the class type.
Parameters:
criteria - the criteria to apply.
clazz - an alternate class or class name.
Returns:
a collection of objects.
Throws:
PersistenceException - on errors.

queryObjects

<T> Collection<T> queryObjects(Class<T> clazz,
                               String attribute,
                               Object value,
                               DBCriteria.Condition condition)
                           throws PersistenceException
Queries objects of the specified class.

Type Parameters:
T - the class type.
Parameters:
clazz - the class to query.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criteria.
Returns:
a collection of objects.
Throws:
PersistenceException - on errors.

queryObjects

<T> Collection<T> queryObjects(String className,
                               String attribute,
                               Object value,
                               DBCriteria.Condition condition)
                           throws PersistenceException
Queries objects of the named class.

Type Parameters:
T - the class type
Parameters:
className - the class name to query.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criteria.
Returns:
a collection of objects.
Throws:
PersistenceException - on errors.

queryIterator

<T> QueryIterator<T> queryIterator(Class<T> clazz,
                                   Object... values)
                               throws PersistenceException
Queries an iterator to objects of the specified class.

Type Parameters:
T - the query type.
Parameters:
clazz - the class to query.
values - the PK(s) of the object.
Returns:
an iterator to a collection of objects.
Throws:
PersistenceException - on errors.

queryIterator

<T> QueryIterator<T> queryIterator(String className,
                                   Object... values)
                               throws PersistenceException
Queries an iterator to objects of the named class.

Type Parameters:
T - the query type.
Parameters:
className - the class name to query.
values - the PK(s) of the object.
Returns:
an iterator to a collection of objects.
Throws:
PersistenceException - on errors.

queryIterator

<T> QueryIterator<T> queryIterator(DBQuery<T> query)
                               throws PersistenceException
Queries an iterator to a collection of objects.

Type Parameters:
T - the query type.
Parameters:
query - the query.
Returns:
an iterator to a collection of objects.
Throws:
PersistenceException - on errors.

queryIterator

<T> QueryIterator<T> queryIterator(DBCriteria<T> criteria,
                                   Object... clazz)
                               throws PersistenceException
Queries an iterator to a collection of objects of the specified criteria.

Type Parameters:
T - the class type.
Parameters:
criteria - the criteria to apply.
clazz - an alternate class or class name.
Returns:
an iterator to a collection of objects.
Throws:
PersistenceException - on errors.

queryIterator

<T> QueryIterator<T> queryIterator(Class<T> clazz,
                                   String attribute,
                                   Object value,
                                   DBCriteria.Condition condition)
                               throws PersistenceException
Queries an iterator to a collection of objects of the specified class.

Type Parameters:
T - the class type.
Parameters:
clazz - the class to query.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criteria.
Returns:
an iterator to a collection of objects.
Throws:
PersistenceException - on errors.

queryIterator

<T> QueryIterator<T> queryIterator(String className,
                                   String attribute,
                                   Object value,
                                   DBCriteria.Condition condition)
                               throws PersistenceException
Queries an iterator to a collection of objects of the named class.

Type Parameters:
T - the class type.
Parameters:
className - the class name to query.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criterion attribute.
Returns:
an iterator to a collection of objects.
Throws:
PersistenceException - on errors.

queryCount

int queryCount(Class<?> clazz,
               Object... values)
Queries the count of objects the specified class.

Parameters:
clazz - the class to query.
values - the PK(s) of the object.
Returns:
the count of objects or -1 if the query fails.

queryCount

int queryCount(String className,
               Object... values)
Queries the count of objects the named class.

Parameters:
className - the class name to query.
values - the PK(s) of the object.
Returns:
the count of objects or -1 if the query fails.

queryCount

int queryCount(DBQuery<?> query)
Queries the count of objects the given query would return.

Parameters:
query - the query.
Returns:
the count of objects or -1 if the query fails.

queryCount

int queryCount(DBCriteria<?> criteria,
               Object... clazz)
Queries the count of objects of the specified criteria.

Parameters:
criteria - the criteria to apply.
clazz - an alternate class or class name.
Returns:
the count of objects or -1 if the query fails.

queryCount

int queryCount(Class<?> clazz,
               String attribute,
               Object value,
               DBCriteria.Condition condition)
Queries the count of objects of the specified class.

Parameters:
clazz - the class to query.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criteria.
Returns:
the count of objects or -1 if the query fails.

queryCount

int queryCount(String className,
               String attribute,
               Object value,
               DBCriteria.Condition condition)
Queries the count of objects of the named class.

Parameters:
className - the class name to query.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criterion attribute.
Returns:
the count of objects or -1 if the query fails.

exists

boolean exists(Object object)
Checks whether an object exists in the repository.

Parameters:
object - the object to check.
Returns:
true if exists, false otherwise.

getObject

Object getObject(Object object)
                 throws PersistenceException
Gets an object from the repository.

Parameters:
object - the object to get.
Returns:
the found object or null.
Throws:
PersistenceException - on errors.

storeObject

void storeObject(Object object)
                 throws PersistenceException
Stores an object to the repository.

Parameters:
object - the object to store.
Throws:
PersistenceException - on errors.

storeObjects

void storeObjects(Collection<?> objects)
                  throws PersistenceException
Stores a collection of objects to the repository as one transaction. If storing of any of the objects fails, the transaction is aborted.

Parameters:
objects - the objects to store.
Throws:
PersistenceException - on errors.

storeReferences

void storeReferences(Object object,
                     String... classNames)
                     throws PersistenceException
Stores an object and its dependencies to the repository.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object to insert.
classNames - the dependent class names.
Throws:
PersistenceException - on errors.

insertObject

void insertObject(Object object)
                  throws PersistenceException
Inserts an object to the repository.

Parameters:
object - the object to insert.
Throws:
PersistenceException - on errors.

insertObjects

void insertObjects(Collection<?> objects)
                   throws PersistenceException
Inserts a collection of objects to the repository as one transaction. If insertion of any of the objects fails, the transaction is aborted.

Parameters:
objects - the objects to insert.
Throws:
PersistenceException - on errors.

insertReferences

void insertReferences(Object object,
                      String... classNames)
                      throws PersistenceException
Inserts an object and its dependencies to the repository.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object to insert.
classNames - the dependent class names.
Throws:
PersistenceException - on errors.

updateObject

void updateObject(Object object)
                  throws PersistenceException
Updates an object in the repository.

Parameters:
object - the object to update.
Throws:
PersistenceException - on errors.

updateObjects

void updateObjects(Collection<?> objects)
                   throws PersistenceException
Updates a collection of objects in the repository as one transaction. If update of any of the objects fails, the transaction is aborted.

Parameters:
objects - the objects to update.
Throws:
PersistenceException - on errors.

updateReferences

void updateReferences(Object object,
                      String... classNames)
                      throws PersistenceException
Updates an object and its dependencies to the repository.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object to insert.
classNames - the dependent class names.
Throws:
PersistenceException - on errors.

mergeObject

Object mergeObject(Object object,
                   AttributeFilter... filter)
                   throws PersistenceException
Merges an object in the repository.

Parameters:
object - the object to merge.
filter - an optional attribute filter.
Returns:
the merged object.
Throws:
PersistenceException - on errors.

mergeReferences

Object mergeReferences(Object object,
                       String... classNames)
                       throws PersistenceException
Merges an object and its dependencies to the repository.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object to merge.
classNames - the dependent class names.
Returns:
the merged object.
Throws:
PersistenceException - on errors.

mergeReferences

Object mergeReferences(Object object,
                       AttributeFilter filter,
                       String... classNames)
                       throws PersistenceException
Merges an object and its dependencies to the repository by applying an attribute filter.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object to merge.
filter - the attribute filter.
classNames - the dependent class names.
Returns:
the merged object.
Throws:
PersistenceException - on errors.

deleteObject

void deleteObject(Object object)
                  throws PersistenceException
Deletes an object from the repository.

Parameters:
object - the object to delete.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(Collection<?> objects)
                   throws PersistenceException
Deletes a collection of objects from the repository as one transaction.

Parameters:
objects - the objects to delete.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(Class<?> clazz)
                   throws PersistenceException
Deletes objects of the specified class from the repository as one transaction.

Parameters:
clazz - the class to delete.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(String className)
                   throws PersistenceException
Deletes objects of the named class from the repository as one transaction.

Parameters:
className - the class name to delete.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(DBQuery<?> query)
                   throws PersistenceException
Deletes query objects from the repository as one transaction.

Parameters:
query - the query.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(DBCriteria<?> criteria,
                   Object... clazz)
                   throws PersistenceException
Deletes objects of the specified criteria as one transaction.

Parameters:
criteria - the criteria to apply.
clazz - an alternate class or class name.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(Class<?> clazz,
                   String attribute,
                   Object value,
                   DBCriteria.Condition condition)
                   throws PersistenceException
Deletes objects of the specified class from the repository as one transaction.

Parameters:
clazz - the class to delete.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criteria.
Throws:
PersistenceException - on errors.

deleteObjects

void deleteObjects(String className,
                   String attribute,
                   Object value,
                   DBCriteria.Condition condition)
                   throws PersistenceException
Deletes objects of the named class from the repository as one transaction.

Parameters:
className - the class name to delete.
attribute - the name of the attribute.
value - the value of the attribute.
condition - the condition for the criteria.
Throws:
PersistenceException - on errors.

deleteReferences

void deleteReferences(Object object,
                      String... classNames)
                      throws PersistenceException
Deletes an object and its dependencies from the repository.

Note that if dependent class names are not given, only the current class of the object is considered as a dependent class.

Parameters:
object - the object to delete.
classNames - the dependent class names.
Throws:
PersistenceException - on errors.

importReferences

void importReferences(Object source,
                      Object target,
                      boolean foreign,
                      AttributeFilter... filter)
                      throws PersistenceException
Imports references from the specified source object to a target object. The references of the persistent source object are first retrieved and then its attributes are imported to the target object. Foreign import can only be performed if the target implements the TransportListener

interface.

Parameters:
source - the source object.
target - the target object.
foreign - true if a foreign import, false otherwise.
filter - an optional attribute filter.
Throws:
PersistenceException - on errors.

exportReferences

void exportReferences(Object source,
                      Object target,
                      boolean foreign,
                      AttributeFilter... filter)
                      throws PersistenceException
Exports references from a source object to a target object. The attributes of the source object are first exported to the persistent target object and then the references of the target object are stored to the repository. Foreign export can only be performed if the source implements the TransportListener

interface.

Parameters:
source - the source object.
target - the target object.
foreign - true if a foreign import, false otherwise.
filter - an optional attribute filter.
Throws:
PersistenceException - on errors.

execute

void execute(String sql)
             throws PersistenceException
Executes an SQL statement.

Note that open transactions may be committed as a side effect.

Parameters:
sql - the statement.
Throws:
PersistenceException - on errors.

execute

void execute(String[] sql)
             throws PersistenceException
Executes SQL statements as a batch.

Note that open transactions may be committed as a side effect.

Parameters:
sql - the statements.
Throws:
PersistenceException - on errors.

isTransactionsSupported

boolean isTransactionsSupported()
Checks whether this persister implementation supports transactions.

Returns:
true if transactions are supported, otherwise false.

isInTransaction

boolean isInTransaction()
Checks whether this persister is performing a transaction.

Returns:
true if in transaction, otherwise false.

beginTransaction

boolean beginTransaction()
Begins a transaction to start updates in the repository.

Nop if transactions are not supported.

Returns:
true if a new transaction is started, false if an existing transaction was already open.

abortTransaction

boolean abortTransaction()
Aborts a transaction to cancel updates to the repository.

Nop if transactions are not supported.

Returns:
true if a transaction is aborted, false if no transaction was open to be aborted.

commitTransaction

boolean commitTransaction()
Commits a transaction to complete updates in the repository.

Nop if transactions are not supported.

Returns:
true if a transaction is commited, false if no transaction was open to be committed.

getRepository

String getRepository(String className)
Gets the name of the repository of the named class.

Parameters:
className - the class name.
Returns:
the name of the repository or null.

load

Collection<?> load(File file)
                   throws PersistenceException
Loads objects from a dump file if this persister supports files.

Parameters:
file - the dump file.
Returns:
a collection of loaded objects.
Throws:
PersistenceException - for loading errors.
UnsupportedOperationException - if not supported.

dump

void dump(Collection<?> objects,
          File file)
          throws PersistenceException
Dumps objects into a dump file if this persister supports files.

Parameters:
objects - a collection of objects to dump.
file - the dump file.
Throws:
PersistenceException - for dumping errors.
UnsupportedOperationException - if not supported.

getLocale

Locale getLocale()
Gets the locale of this persister.

Returns:
the locale or the default.

setLocale

void setLocale(Locale loc)
Sets the locale of this persister.

Parameters:
loc - the locale.

getPrincipal

Principal getPrincipal()
Gets the principal of this persister.

Returns:
the principal or null.

getUserId

Object getUserId()
Gets the user id of this persister.

Returns:
the user id or null.

getGroupId

Object getGroupId()
Gets the group id of this persister.

Returns:
the group id or null.

getRootGroupId

Object getRootGroupId()
Gets the root group id of this persister.

Returns:
the root group id or null.

getAttributeValue

Object getAttributeValue(Object object,
                         String field)
                         throws AttributeNotFoundException
Gets the reflected attribute value of the specified object.

Parameters:
object - the persistent object.
field - the field.
Returns:
the value.
Throws:
AttributeNotFoundException - if not found.

setAttributeValue

void setAttributeValue(Object object,
                       String field,
                       Object value)
                       throws AttributeNotFoundException,
                              InvalidAttributeValueException
Sets the reflected attribute value of the specified object.

Parameters:
object - the persistent object.
field - the field.
value - the value.
Throws:
AttributeNotFoundException - if not found.
InvalidAttributeValueException - if invalid.

getValidatedValue

Object getValidatedValue(Object object,
                         String field)
                         throws AttributeNotFoundException
Gets the validated attribute value of the specified object.

Parameters:
object - the persistent object.
field - the field.
Returns:
the value.
Throws:
AttributeNotFoundException - if not found.

setValidatedValue

void setValidatedValue(Object object,
                       String field,
                       Object value)
                       throws AttributeNotFoundException,
                              InvalidAttributeValueException
Sets the validated attribute value of the specified object.

Parameters:
object - the persistent object.
field - the field.
value - the value.
Throws:
AttributeNotFoundException - if not found.
InvalidAttributeValueException - if invalid.

getAttributeValues

Object[] getAttributeValues(Object object,
                            String field)
                            throws AttributeNotFoundException
Gets the reflected attribute values of the specified object.

Parameters:
object - the persistent object.
field - the field.
Returns:
the values.
Throws:
AttributeNotFoundException - if not found.

getIdentityValue

Object getIdentityValue(Object object)
                        throws AttributeNotFoundException
Gets the identity attribute value of the specified object.

Parameters:
object - the object.
Returns:
the identity value.
Throws:
AttributeNotFoundException - if not found.

setIdentityValue

void setIdentityValue(Object object,
                      Object value)
                      throws AttributeNotFoundException,
                             InvalidAttributeValueException
Sets the identity attribute value of the specified object.

Parameters:
object - the object.
value - the identity value.
Throws:
InvalidAttributeValueException - if the value is invalid.
AttributeNotFoundException - if not found.

getIdentityValues

Object[] getIdentityValues(Object object)
                           throws AttributeNotFoundException
Gets an array of identity attribute values of the specified object.

Parameters:
object - the object.
Returns:
an array of identity values.
Throws:
AttributeNotFoundException - if not found.

setIdentityValues

void setIdentityValues(Object object,
                       Object[] values)
                       throws InvalidAttributeValueException,
                              AttributeNotFoundException
Sets an array of identity attribute values of the specified object.

Parameters:
object - the object.
values - an array of identity values.
Throws:
InvalidAttributeValueException - if the value is invalid.
AttributeNotFoundException - if not found.

resetIdentityValues

void resetIdentityValues(Object object)
                         throws InvalidAttributeValueException,
                                AttributeNotFoundException
Resets identity attribute values of the specified object to nulls, if they are auto incremental.

Parameters:
object - the object.
Throws:
InvalidAttributeValueException - if the value is invalid.
AttributeNotFoundException - if not found.

getReferenceValue

<T> T getReferenceValue(Object object,
                        String field)
                    throws AttributeNotFoundException
Gets the referenced object of the specified object. The first one is applied in 1:n relations.

Type Parameters:
T - the referenced type.
Parameters:
object - the object.
field - the reference field.
Returns:
the referenced object.
Throws:
AttributeNotFoundException - if not found.

getReferenceValues

<T> List<T> getReferenceValues(Object object,
                               String field)
                           throws AttributeNotFoundException
Gets a list of referenced objects of the specified object.

Type Parameters:
T - the referenced type.
Parameters:
object - the object.
field - the reference field.
Returns:
a read-only list of referenced objects.
Throws:
AttributeNotFoundException - if not found.

isPersistentObject

boolean isPersistentObject(Object object)
Checks whether the specified object is persistent.

Parameters:
object - the object.
Returns:
true for a persistent object, false otherwise.

getPersisterFactory

PersisterFactory getPersisterFactory()
Gets the persister factory of this persister.

Returns:
the persister factory.

getMBeanServer

MBeanServer getMBeanServer()
Gets the MBean server of this persister.

Returns:
the MBean server.


Copyright © 2004 The Norther Organization. All rights reserved.