|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.orm.toplink.TopLinkAccessor org.springframework.orm.toplink.TopLinkTemplate
public class TopLinkTemplate
Helper class that simplifies TopLink data access code, and converts
TopLinkExceptions into unchecked DataAccessExceptions, following the
org.springframework.dao
exception hierarchy.
The central method is execute
, supporting TopLink access code
implementing the TopLinkCallback
interface. It provides TopLink Session
handling such that neither the TopLinkCallback implementation nor the calling
code needs to explicitly care about retrieving/closing TopLink Sessions,
or handling Session lifecycle exceptions. For typical single step actions,
there are various convenience methods (read, readAll, merge, delete, etc).
Can be used within a service implementation via direct instantiation with a SessionFactory reference, or get prepared in an application context and given to services as bean reference. Note: The SessionFactory should always be configured as bean in the application context, in the first case given to the service directly, in the second case to the prepared template.
This class can be considered as direct alternative to working with the raw
TopLink Session API (through SessionFactoryUtils.getSession()
).
The major advantage is its automatic conversion to DataAccessExceptions, the
major disadvantage that no checked application exceptions can get thrown from
within data access code. Corresponding checks and the actual throwing of such
exceptions can often be deferred to after callback execution, though.
LocalSessionFactoryBean
is the preferred way of obtaining a reference
to a specific TopLink SessionFactory. It will usually be configured to
create ClientSessions for a ServerSession held by it, allowing for seamless
multi-threaded execution. The Spring application context will manage its lifecycle,
initializing and shutting down the factory as part of the application.
Thanks to Slavik Markovich for implementing the initial TopLink support prototype!
TopLinkAccessor.setSessionFactory(org.springframework.orm.toplink.SessionFactory)
,
TopLinkCallback
,
Session
,
TopLinkInterceptor
,
LocalSessionFactoryBean
,
TopLinkTransactionManager
,
JtaTransactionManager
Field Summary |
---|
Fields inherited from class org.springframework.orm.toplink.TopLinkAccessor |
---|
logger |
Constructor Summary | |
---|---|
TopLinkTemplate()
Create a new TopLinkTemplate instance. |
|
TopLinkTemplate(SessionFactory sessionFactory)
Create a new TopLinkTemplate instance. |
|
TopLinkTemplate(SessionFactory sessionFactory,
boolean allowCreate)
Create a new TopLinkTemplate instance. |
Method Summary | |
---|---|
Object |
copy(Object entity)
Create a detached copy of the given entity object, using TopLink's default ObjectCopyingPolicy. |
Object |
copy(Object entity,
oracle.toplink.sessions.ObjectCopyingPolicy copyingPolicy)
Create a detached copy of the given entity object. |
List |
copyAll(Collection entities)
Create detached copies of all given entity objects, using TopLink's default ObjectCopyingPolicy. |
List |
copyAll(Collection entities,
oracle.toplink.sessions.ObjectCopyingPolicy copyingPolicy)
Create detached copies of all given entity objects. |
Object |
deepMerge(Object entity)
Reassociate the given entity copy with the current UnitOfWork, using deep merging of all contained entities. |
void |
delete(Object entity)
Delete the given entity. |
void |
deleteAll(Collection entities)
Delete all given entities. |
Object |
execute(TopLinkCallback action)
Execute the action specified by the given action object within a TopLink Session. |
List |
executeFind(TopLinkCallback action)
Execute the specified action assuming that the result object is a Collection. |
Object |
executeNamedQuery(Class entityClass,
String queryName)
Execute a given named query with the given arguments. |
Object |
executeNamedQuery(Class entityClass,
String queryName,
boolean enforceReadOnly)
Execute a given named query with the given arguments. |
Object |
executeNamedQuery(Class entityClass,
String queryName,
Object[] args)
Execute a given named query with the given arguments. |
Object |
executeNamedQuery(Class entityClass,
String queryName,
Object[] args,
boolean enforceReadOnly)
Execute a given named query with the given arguments. |
Object |
executeQuery(oracle.toplink.queryframework.DatabaseQuery query)
Execute the given query object with the given arguments. |
Object |
executeQuery(oracle.toplink.queryframework.DatabaseQuery query,
boolean enforceReadOnly)
Execute the given query object with the given arguments. |
Object |
executeQuery(oracle.toplink.queryframework.DatabaseQuery query,
Object[] args)
Execute the given query object with the given arguments. |
Object |
executeQuery(oracle.toplink.queryframework.DatabaseQuery query,
Object[] args,
boolean enforceReadOnly)
Execute the given query object with the given arguments. |
boolean |
isAllowCreate()
Return if a new Session should be created if no thread-bound found. |
Object |
merge(Object entity)
Reassociate the given entity copy with the current UnitOfWork, using simple merging. |
Object |
mergeWithReferences(Object entity)
Reassociate the given entity copy with the current UnitOfWork, using merging with all references from this clone. |
Object |
read(Class entityClass,
oracle.toplink.queryframework.Call call)
Read an entity instance of the given class, as returned by the given call. |
Object |
read(Class entityClass,
oracle.toplink.queryframework.Call call,
boolean enforceReadOnly)
Read an entity instance of the given class, as returned by the given call. |
Object |
read(Class entityClass,
oracle.toplink.expressions.Expression expression)
Read an entity instance of the given class that matches the given expression. |
Object |
read(Class entityClass,
oracle.toplink.expressions.Expression expression,
boolean enforceReadOnly)
Read an entity instance of the given class that matches the given expression. |
List |
readAll(Class entityClass)
Read all entity instances of the given class. |
List |
readAll(Class entityClass,
boolean enforceReadOnly)
Read all entity instances of the given class. |
List |
readAll(Class entityClass,
oracle.toplink.queryframework.Call call)
Read all entity instances of the given class, as returned by the given call. |
List |
readAll(Class entityClass,
oracle.toplink.queryframework.Call call,
boolean enforceReadOnly)
Read all entity instances of the given class, as returned by the given call. |
List |
readAll(Class entityClass,
oracle.toplink.expressions.Expression expression)
Read all entity instances of the given class that match the given expression. |
List |
readAll(Class entityClass,
oracle.toplink.expressions.Expression expression,
boolean enforceReadOnly)
Read all entity instances of the given class that match the given expression. |
Object |
readAndCopy(Class entityClass,
Object id)
Read the entity instance of the given class with the given id, throwing an exception if not found. |
Object |
readAndCopy(Class entityClass,
Object[] keys)
Read the entity instance of the given class with the given composite id, throwing an exception if not found. |
Object |
readAndCopy(Class entityClass,
Object[] keys,
boolean enforceReadOnly)
Read the entity instance of the given class with the given composite id, throwing an exception if not found. |
Object |
readAndCopy(Class entityClass,
Object id,
boolean enforceReadOnly)
Read the entity instance of the given class with the given id, throwing an exception if not found. |
Object |
readById(Class entityClass,
Object id)
Read the entity instance of the given class with the given id, throwing an exception if not found. |
Object |
readById(Class entityClass,
Object[] keys)
Read the entity instance of the given class with the given composite id, throwing an exception if not found. |
Object |
readById(Class entityClass,
Object[] keys,
boolean enforceReadOnly)
Read the entity instance of the given class with the given composite id, throwing an exception if not found. |
Object |
readById(Class entityClass,
Object id,
boolean enforceReadOnly)
Read the entity instance of the given class with the given id, throwing an exception if not found. |
Object |
refresh(Object entity)
Refresh the given entity object, returning the refreshed object. |
Object |
refresh(Object entity,
boolean enforceReadOnly)
Refresh the given entity object, returning the refreshed object. |
List |
refreshAll(Collection entities)
Refresh the given entity objects, returning the corresponding refreshed objects. |
List |
refreshAll(Collection entities,
boolean enforceReadOnly)
Refresh the given entity objects, returning the corresponding refreshed objects. |
Object |
register(Object entity)
Register the given (new or existing) entity with the current UnitOfWork. |
List |
registerAll(Collection entities)
Register all given entities with the current UnitOfWork. |
Object |
registerExisting(Object entity)
Register the given existing entity with the current UnitOfWork. |
void |
registerNew(Object entity)
Register the given new entity with the current UnitOfWork. |
void |
setAllowCreate(boolean allowCreate)
Set if a new Session should be created when no transactional Session can be found for the current thread. |
Object |
shallowMerge(Object entity)
Reassociate the given entity copy with the current UnitOfWork, using shallow merging of the entity instance. |
Methods inherited from class org.springframework.orm.toplink.TopLinkAccessor |
---|
afterPropertiesSet, convertTopLinkAccessException, getJdbcExceptionTranslator, getSessionFactory, setJdbcExceptionTranslator, setSessionFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TopLinkTemplate()
public TopLinkTemplate(SessionFactory sessionFactory)
public TopLinkTemplate(SessionFactory sessionFactory, boolean allowCreate)
allowCreate
- if a new Session should be created if no thread-bound foundMethod Detail |
---|
public void setAllowCreate(boolean allowCreate)
TopLinkTemplate is aware of a corresponding Session bound to the current thread, for example when using TopLinkTransactionManager. If allowCreate is true, a new non-transactional Session will be created if none found, which needs to be closed at the end of the operation. If false, an IllegalStateException will get thrown in this case.
SessionFactoryUtils.getSession(SessionFactory, boolean)
public boolean isAllowCreate()
public Object execute(TopLinkCallback action) throws DataAccessException
TopLinkOperations
Note: Callback code is not supposed to handle transactions itself! Use an appropriate transaction manager like TopLinkTransactionManager.
execute
in interface TopLinkOperations
action
- callback object that specifies the TopLink action
null
DataAccessException
- in case of TopLink errorsTopLinkTransactionManager
,
org.springframework.dao
,
org.springframework.transaction
,
Session
public List executeFind(TopLinkCallback action) throws DataAccessException
TopLinkOperations
executeFind
in interface TopLinkOperations
action
- callback object that specifies the TopLink action
null
DataAccessException
- in case of TopLink errorspublic Object executeNamedQuery(Class entityClass, String queryName) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
executeNamedQuery
in interface TopLinkOperations
entityClass
- the entity class that has the named query descriptorqueryName
- the name of the query
DataAccessException
- in case of TopLink errorsSession.executeQuery(String, Class)
public Object executeNamedQuery(Class entityClass, String queryName, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
executeNamedQuery
in interface TopLinkOperations
entityClass
- the entity class that has the named query descriptorqueryName
- the name of the queryenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.executeQuery(String, Class)
public Object executeNamedQuery(Class entityClass, String queryName, Object[] args) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
executeNamedQuery
in interface TopLinkOperations
entityClass
- the entity class that has the named query descriptorqueryName
- the name of the queryargs
- the arguments for the query (can be null
)
DataAccessException
- in case of TopLink errorsSession.executeQuery(String, Class, java.util.Vector)
public Object executeNamedQuery(Class entityClass, String queryName, Object[] args, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
executeNamedQuery
in interface TopLinkOperations
entityClass
- the entity class that has the named query descriptorqueryName
- the name of the queryargs
- the arguments for the query (can be null
)enforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.executeQuery(String, Class, java.util.Vector)
public Object executeQuery(oracle.toplink.queryframework.DatabaseQuery query) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
executeQuery
in interface TopLinkOperations
query
- the query object to execute (for example,
a ReadObjectQuery or ReadAllQuery instance)
DataAccessException
- in case of TopLink errorsSession.executeQuery(oracle.toplink.queryframework.DatabaseQuery)
public Object executeQuery(oracle.toplink.queryframework.DatabaseQuery query, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
executeQuery
in interface TopLinkOperations
query
- the query object to execute (for example,
a ReadObjectQuery or ReadAllQuery instance)enforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.executeQuery(oracle.toplink.queryframework.DatabaseQuery)
public Object executeQuery(oracle.toplink.queryframework.DatabaseQuery query, Object[] args) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
executeQuery
in interface TopLinkOperations
query
- the query object to execute (for example,
a ReadObjectQuery or ReadAllQuery instance)args
- the arguments for the query (can be null
)
DataAccessException
- in case of TopLink errorsSession.executeQuery(oracle.toplink.queryframework.DatabaseQuery, java.util.Vector)
public Object executeQuery(oracle.toplink.queryframework.DatabaseQuery query, Object[] args, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
executeQuery
in interface TopLinkOperations
query
- the query object to execute (for example,
a ReadObjectQuery or ReadAllQuery instance)args
- the arguments for the query (can be null
)enforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.executeQuery(oracle.toplink.queryframework.DatabaseQuery, java.util.Vector)
public List readAll(Class entityClass) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readAll
in interface TopLinkOperations
entityClass
- the entity class
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class)
public List readAll(Class entityClass, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readAll
in interface TopLinkOperations
entityClass
- the entity classenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class)
public List readAll(Class entityClass, oracle.toplink.expressions.Expression expression) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readAll
in interface TopLinkOperations
entityClass
- the entity classexpression
- the TopLink expression to match,
usually built through the TopLink ExpressionBuilder
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.expressions.Expression)
,
ExpressionBuilder
public List readAll(Class entityClass, oracle.toplink.expressions.Expression expression, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readAll
in interface TopLinkOperations
entityClass
- the entity classexpression
- the TopLink expression to match,
usually built through the TopLink ExpressionBuilderenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.expressions.Expression)
,
ExpressionBuilder
public List readAll(Class entityClass, oracle.toplink.queryframework.Call call) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readAll
in interface TopLinkOperations
entityClass
- the entity classcall
- the TopLink Call object to apply (either a SQLCall or an EJBQLCall)
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.queryframework.Call)
,
oracle.toplink.queryframework.SQLCall
,
oracle.toplink.queryframework.EJBQLCall
public List readAll(Class entityClass, oracle.toplink.queryframework.Call call, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readAll
in interface TopLinkOperations
entityClass
- the entity classcall
- the TopLink Call object to apply (either a SQLCall or an EJBQLCall)enforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.expressions.Expression)
,
oracle.toplink.queryframework.SQLCall
,
oracle.toplink.queryframework.EJBQLCall
public Object read(Class entityClass, oracle.toplink.expressions.Expression expression) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
read
in interface TopLinkOperations
entityClass
- the entity classexpression
- the TopLink expression to match,
usually built through the TopLink ExpressionBuilder
null
if none found
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.expressions.Expression)
,
ExpressionBuilder
public Object read(Class entityClass, oracle.toplink.expressions.Expression expression, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
read
in interface TopLinkOperations
entityClass
- the entity classexpression
- the TopLink expression to match,
usually built through the TopLink ExpressionBuilderenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
null
if none found
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.expressions.Expression)
,
ExpressionBuilder
public Object read(Class entityClass, oracle.toplink.queryframework.Call call) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
read
in interface TopLinkOperations
entityClass
- the entity classcall
- the TopLink Call object to apply (either a SQLCall or an EJBQLCall)
null
if none found
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.queryframework.Call)
,
oracle.toplink.queryframework.SQLCall
,
oracle.toplink.queryframework.EJBQLCall
public Object read(Class entityClass, oracle.toplink.queryframework.Call call, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
read
in interface TopLinkOperations
entityClass
- the entity classcall
- the TopLink Call object to apply (either a SQLCall or an EJBQLCall)enforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
null
if none found
DataAccessException
- in case of TopLink errorsSession.readAllObjects(Class, oracle.toplink.expressions.Expression)
,
oracle.toplink.queryframework.SQLCall
,
oracle.toplink.queryframework.EJBQLCall
public Object readById(Class entityClass, Object id) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readById
in interface TopLinkOperations
entityClass
- the entity classid
- the id of the desired object
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
public Object readById(Class entityClass, Object id, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readById
in interface TopLinkOperations
entityClass
- the entity classid
- the id of the desired objectenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
public Object readById(Class entityClass, Object[] keys) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readById
in interface TopLinkOperations
entityClass
- the entity classkeys
- the composite id elements of the desired object
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
public Object readById(Class entityClass, Object[] keys, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readById
in interface TopLinkOperations
entityClass
- the entity classkeys
- the composite id elements of the desired objectenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
public Object readAndCopy(Class entityClass, Object id) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readAndCopy
in interface TopLinkOperations
entityClass
- the entity classid
- the id of the desired object
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
,
Session.copyObject(Object)
public Object readAndCopy(Class entityClass, Object id, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readAndCopy
in interface TopLinkOperations
entityClass
- the entity classid
- the id of the desired objectenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
,
Session.copyObject(Object)
public Object readAndCopy(Class entityClass, Object[] keys) throws DataAccessException
TopLinkOperations
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
readAndCopy
in interface TopLinkOperations
entityClass
- the entity classkeys
- the composite id elements of the desired object
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
,
Session.copyObject(Object)
public Object readAndCopy(Class entityClass, Object[] keys, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
readAndCopy
in interface TopLinkOperations
entityClass
- the entity classkeys
- the composite id elements of the desired objectenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
ObjectRetrievalFailureException
- if not found
DataAccessException
- in case of TopLink errorsReadObjectQuery.setSelectionKey(java.util.Vector)
,
Session.copyObject(Object)
public Object copy(Object entity) throws DataAccessException
TopLinkOperations
copy
in interface TopLinkOperations
entity
- the entity object to copy
DataAccessException
- in case of TopLink errorsSession.copyObject(Object)
public Object copy(Object entity, oracle.toplink.sessions.ObjectCopyingPolicy copyingPolicy) throws DataAccessException
TopLinkOperations
copy
in interface TopLinkOperations
entity
- the entity object to copycopyingPolicy
- the TopLink ObjectCopyingPolicy to apply
DataAccessException
- in case of TopLink errorsSession.copyObject(Object, oracle.toplink.sessions.ObjectCopyingPolicy)
public List copyAll(Collection entities) throws DataAccessException
TopLinkOperations
copyAll
in interface TopLinkOperations
entities
- the entity objects to copy
DataAccessException
- in case of TopLink errorsSession.copyObject(Object)
public List copyAll(Collection entities, oracle.toplink.sessions.ObjectCopyingPolicy copyingPolicy) throws DataAccessException
TopLinkOperations
copyAll
in interface TopLinkOperations
entities
- the entity objects to copycopyingPolicy
- the TopLink ObjectCopyingPolicy to apply
DataAccessException
- in case of TopLink errorsSession.copyObject(Object)
public Object refresh(Object entity) throws DataAccessException
TopLinkOperations
The returned object will only be different from the passed-in object if the passed-in object is not the currently registered version of the corresponding entity.
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
refresh
in interface TopLinkOperations
entity
- the entity object to refresh
DataAccessException
- in case of TopLink errorsSession.refreshObject(Object)
public Object refresh(Object entity, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
The returned object will only be different from the passed-in object if the passed-in object is not the currently registered version of the corresponding entity.
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
refresh
in interface TopLinkOperations
entity
- the entity object to refreshenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.refreshObject(Object)
public List refreshAll(Collection entities) throws DataAccessException
TopLinkOperations
A returned object will only be different from the corresponding passed-in object if the passed-in object is not the currently registered version of the corresponding entity.
Retrieves read-write objects from the TopLink UnitOfWork in case of a non-read-only transaction, and read-only objects else.
refreshAll
in interface TopLinkOperations
entities
- the entity objects to refresh
DataAccessException
- in case of TopLink errorsSession.refreshObject(Object)
public List refreshAll(Collection entities, boolean enforceReadOnly) throws DataAccessException
TopLinkOperations
A returned object will only be different from the corresponding passed-in object if the passed-in object is not the currently registered version of the corresponding entity.
refreshAll
in interface TopLinkOperations
entities
- the entity objects to refreshenforceReadOnly
- whether to always retrieve read-only objects from
the plain TopLink Session (else, read-write objects will be retrieved
from the TopLink UnitOfWork in case of a non-read-only transaction)
DataAccessException
- in case of TopLink errorsSession.refreshObject(Object)
public Object register(Object entity)
TopLinkOperations
The entity will be checked for existence, according to TopLink's
configured existence checking policy. To avoid the (potentially costly)
existence check, consider using the specific registerNew
or registerExisting
method.
Do not edit the passed-in object any further afterwards.
register
in interface TopLinkOperations
entity
- the entity to register
UnitOfWork.registerObject(Object)
,
TopLinkOperations.registerNew(Object)
,
TopLinkOperations.registerExisting(Object)
public List registerAll(Collection entities)
TopLinkOperations
registerAll
in interface TopLinkOperations
entities
- the entities to register
UnitOfWork.registerAllObjects(java.util.Collection)
public void registerNew(Object entity)
TopLinkOperations
registerNew
in interface TopLinkOperations
entity
- the new entity to registerUnitOfWork.registerNewObject(Object)
public Object registerExisting(Object entity)
TopLinkOperations
registerExisting
in interface TopLinkOperations
entity
- the existing entity to register
UnitOfWork.registerExistingObject(Object)
public Object merge(Object entity) throws DataAccessException
TopLinkOperations
The given object will not be reassociated itself: instead, the state will be copied onto the persistent object with the same identifier. In case of a new entity, merge will copy to a registered object as well, but will also update the identifier of the passed-in object.
merge
in interface TopLinkOperations
entity
- the updated copy to merge
DataAccessException
- in case of TopLink errorsUnitOfWork.mergeClone(Object)
public Object deepMerge(Object entity) throws DataAccessException
TopLinkOperations
The given object will not be reassociated itself: instead, the state will be copied onto the persistent object with the same identifier. In case of a new entity, merge will register a copy as well, but will also update the identifier of the passed-in object.
deepMerge
in interface TopLinkOperations
entity
- the updated copy to merge
DataAccessException
- in case of TopLink errorsUnitOfWork.deepMergeClone(Object)
public Object shallowMerge(Object entity) throws DataAccessException
TopLinkOperations
The given object will not be reassociated itself: instead, the state will be copied onto the persistent object with the same identifier. In case of a new entity, merge will register a copy as well, but will also update the identifier of the passed-in object.
shallowMerge
in interface TopLinkOperations
entity
- the updated copy to merge
DataAccessException
- in case of TopLink errorsUnitOfWork.shallowMergeClone(Object)
public Object mergeWithReferences(Object entity) throws DataAccessException
TopLinkOperations
The given object will not be reassociated itself: instead, the state will be copied onto the persistent object with the same identifier. In case of a new entity, merge will register a copy as well, but will also update the identifier of the passed-in object.
mergeWithReferences
in interface TopLinkOperations
entity
- the updated copy to merge
DataAccessException
- in case of TopLink errorsUnitOfWork.mergeCloneWithReferences(Object)
public void delete(Object entity) throws DataAccessException
TopLinkOperations
delete
in interface TopLinkOperations
entity
- the entity to delete
DataAccessException
- in case of TopLink errorsUnitOfWork.deleteObject(Object)
public void deleteAll(Collection entities) throws DataAccessException
TopLinkOperations
deleteAll
in interface TopLinkOperations
entities
- the entities to delete
DataAccessException
- in case of TopLink errorsUnitOfWork.deleteAllObjects(java.util.Collection)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |