public interface PersistenceProvider extends Provider
PersistenceProviders are responsible for creating, updating, querying, copying and deleting data objects.
DataObjectTypes the PersistenceProvider supports must be queried through handles(Class)
before interaction
with the PersistenceProvider.
Modifier and Type | Method and Description |
---|---|
<T> T |
copyInstance(T dataObject,
CopyOption... options)
Returns a copy of the given data object instance.
|
void |
delete(Object dataObject)
Deletes a given data object.
|
<T> void |
deleteAll(Class<T> type)
Deletes all data objects based on the given type.
|
<T> void |
deleteMatching(Class<T> type,
QueryByCriteria queryByCriteria)
Deletes data objects based on the given criteria
|
<T> T |
find(Class<T> type,
Object id)
Invoked to retrieve a data object instance by a single primary key field or id object.
|
<T> QueryResults<T> |
findAll(Class<T> type)
Retrieves all data objects for the given type.
|
<T> QueryResults<T> |
findMatching(Class<T> type,
QueryByCriteria queryByCriteria)
Executes a query for the given data object.
|
void |
flush(Class<?> type)
Flush any outstanding changes within the current context for the provider pertaining to the given data object
Class type.
|
boolean |
handles(Class<?> type)
Indicates whether or not this provider handles persistence for the given data object type.
|
<T> T |
save(T dataObject,
PersistenceOption... options)
Saves the given data object, determining whether or not this is a new data object which is being created, or an
existing one which should be updated.
|
<T> T save(T dataObject, PersistenceOption... options)
Optional persistence options can be passed to indicate whether or not linking should be performed prior to persistence and whether or not validation should be performed. By default, linking is performed as well as validation.
T
- the data object class typedataObject
- the data object to saveoptions
- the options to use when saving the data objectIllegalArgumentException
- if dataObject
is not a valid data objectorg.springframework.dao.DataAccessException
- if data access fails<T> T find(Class<T> type, Object id)
In the case of a compound primary key consisting of multiple attributes on the data object, a CompoundKey can be passed in order to encapsulate these into a single argument.
T
- the data object class typetype
- the type of the data object to findid
- the id representing the primary key of the data object to findIllegalArgumentException
- if type
does not denote a data object type or id
is not a valid
type for the data object's primary key or is nullorg.springframework.dao.DataAccessException
- if data access fails<T> QueryResults<T> findMatching(Class<T> type, QueryByCriteria queryByCriteria)
If the given QueryByCriteria is empty or null, then all data objects for the given type will be returned. Depending on the given criteria and the implementation for the query execution, not all matching results may be returned. The QueryResults will contain information on whether or not there are additional results which can be used for paging and similar functionality.
T
- the data object class typetype
- the type of the data objects to queryqueryByCriteria
- query object, can contain sorting and page request configurationIllegalArgumentException
- if type
does not denote a data object type or if queryByCriteria
is nullorg.springframework.dao.DataAccessException
- if data access fails<T> QueryResults<T> findAll(Class<T> type)
T
- the data object class typetype
- the type of data objects to findIllegalArgumentException
- if type is null.void delete(Object dataObject)
dataObject
- the data object to deleteIllegalArgumentException
- if dataObject
is not a valid data objectorg.springframework.dao.DataAccessException
- if data access fails<T> void deleteMatching(Class<T> type, QueryByCriteria queryByCriteria)
If the given criteria is empty or null than an IllegalArgumentException
will be thrown.
If the given type is null then an IllegalArgumentException
will be thrown.
type
- the type of data objectqueryByCriteria
- criteria to filter byIllegalArgumentException
- if the criteria or criteria predicate is nullorg.springframework.dao.DataAccessException
- if data access fails<T> void deleteAll(Class<T> type)
T
- the data object class typetype
- the type of data objects to deleteIllegalArgumentException
- if the class type is nullorg.springframework.dao.DataAccessException
- if data access fails<T> T copyInstance(T dataObject, CopyOption... options)
The method of copying is provider dependent, and will handle instances (including nested) using whatever measures might be required to deal with the quirks of said provider (e.g. fetching lazy loaded relations).
T
- the type of the data objectdataObject
- the data object to copyboolean handles(Class<?> type)
Responsibility on with the caller to call prior to invocation of any other PersistenceProvider methods to ensure the data objects of the right type are passed.
type
- the data object type to checkvoid flush(Class<?> type)
If an implementation of this interface does not support or require the concept of "flushing", this method can be ignored. However, when used, this must purge *all* cache items for the given types from all caches managed by this provider.
type
- the type of the data object for which to perform the flush. This should be used to identify the
context in which to perform the flush.Copyright © 2005–2014 The Kuali Foundation. All rights reserved.