public interface DataObjectService
Contains basic data access and query operations for supported data objects. Also provides access to the
MetadataRepository
which contains information about the structure and relationships between data objects.
This service supports the ability to create a DataObjectWrapper
for a given data object. This
wrapper allows for accessing and manipulating properties within the data object as well as performing various
metadata-aware operations on the data object.
This service is meant to act as a facade to specific persistence and query-capable solutions and data stores. Implementations of this service may provide transactional capabilities where it makes sense to do so (and depending on the transactional support of the backend persistence technology). The documentation for the specific implementation of DataObjectService that is being used should be consulted for specifics on transaction semantics.
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)
Removes all records for the given data object type
|
<T> void |
deleteMatching(Class<T> type,
QueryByCriteria queryByCriteria)
Deletes records for the given type and matching 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)
Executes a query for the given data object returning all data objects for the given type.
|
<T> QueryResults<T> |
findMatching(Class<T> type,
QueryByCriteria queryByCriteria)
Executes a query for the given data object.
|
<T> T |
findUnique(Class<T> type,
QueryByCriteria queryByCriteria)
Executes a query for the data object matching the given queryByCriteria and expecting a single unique result to
be returned.
|
void |
flush(Class<?> type)
Flushes any outstanding work to the backend data store.
|
MetadataRepository |
getMetadataRepository()
Returns the MetadataRepository which provides access to all data object metadata known to the system.
|
<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> boolean |
supports(Class<T> type)
Returns whether the DataObjectService supports the given type, where
"supports" means that there is at least one PersistenceProvider that handles the given type.
|
<T> DataObjectWrapper<T> |
wrap(T dataObject)
Wraps the given data object in an accessor which provides numerous utility and helper methods related to
accessing data and attributes on the data object.
|
<T> T find(Class<T> type, Object id)
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 failsCompoundKey
<T> QueryResults<T> findMatching(Class<T> type, QueryByCriteria queryByCriteria)
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, also if the
queryByCriteria
is null or empty.org.springframework.dao.DataAccessException
- if data access fails<T> QueryResults<T> findAll(Class<T> type)
T
- the data object class typetype
- tye type of data objects to queryIllegalArgumentException
- if type
is null.org.springframework.dao.DataAccessException
- if data access fails.<T> T findUnique(Class<T> type, QueryByCriteria queryByCriteria)
IncorrectResultSizeDataAccessException
will be
thrown.T
- the data object class typetype
- the type of the data object to queryqueryByCriteria
- query object defining the criteria for the queryIllegalArgumentException
- if type
does not denote a data object typeorg.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one object matched the given criteriavoid 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)
type
- the type of data objects to deletequeryByCriteria
- query objectIllegalArgumentException
- if type
is null or if the QueryByCriteria
is null or emptyorg.springframework.dao.DataAccessException
- if data access fails<T> void deleteAll(Class<T> type)
T
- the data object class type.type
- the type of data objectsIllegalArgumentException
- if type
is nullorg.springframework.dao.DataAccessException
- if data access fails<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. By default, linking is performed.
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 failsvoid flush(Class<?> type)
Depending on the backend persistence implementation for the given type, this method may or may not do anything.
type
- the type of the data object for which to perform the flush. This is primarily used to identify the
context in which to perform the flush.MetadataRepository getMetadataRepository()
<T> DataObjectWrapper<T> wrap(T dataObject)
T
- the type of the data objectdataObject
- the data object to wrap, must be non-nullIllegalArgumentException
- if the given data object is null or an invalid data object type<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 copy<T> boolean supports(Class<T> type)
type
- the data object typeCopyright © 2005–2015 The Kuali Foundation. All rights reserved.