org.loom.persistence
Interface ExtendedEntityManager

All Superinterfaces:
javax.persistence.EntityManager
All Known Subinterfaces:
HibernateExtendedEntityManager
All Known Implementing Classes:
AbstractExtendedEntityManager, HibernateExtendedEntityManagerImpl, TransactionalService

public interface ExtendedEntityManager
extends javax.persistence.EntityManager

Interface that combines EntityManager operations and extended operations.


Method Summary
 void evict(java.lang.Object entity)
          Remove this instance from the session cache.
<T> T
find(java.lang.Class<T> clazz, java.lang.Object id)
          Retrieves a single persistent instance from the database
<T> java.util.List<T>
find(java.lang.String queryString, java.lang.Object... params)
          Retrieves a non-paged query.
<T> java.util.List<T>
findAll(java.lang.Class<T> clazz)
          Retrieves all records for a specified persistent class This method should be used with care, as it could instantiate huge amounts of data.
<T> java.util.List<T>
findNamed(java.lang.String namedQuery, java.lang.Object... params)
          Retrieves a non-paged query This method should be used with care, as it could instantiate huge amounts of data.
<T> T
findNamedSingle(java.lang.String namedQuery, java.lang.Object... params)
          Execute a query that retrieves a single object.
<T> T
findSingle(java.lang.String queryString, java.lang.Object... params)
           
 java.lang.String getIdPropertyName(java.lang.Class<?> clazz)
           
 java.lang.String getVersionPropertyName(java.lang.Class<?> clazz)
           
<T> T
getVersionValue(java.lang.Object entity)
           
<T> PagedListData<T>
query(PagedListCriteria criteria)
          Retrieve a paged query.
<T> T
remove(java.lang.Class<T> clazz, java.lang.Object id)
          Removes a persistent instance
 void setReadOnly(java.lang.Object entity, boolean readOnly)
          Sets an instance to readOnly.
 int update(java.lang.String queryString, java.lang.Object... params)
          Execute a query that updates the database.
 
Methods inherited from interface javax.persistence.EntityManager
clear, close, contains, createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, flush, getDelegate, getFlushMode, getReference, getTransaction, isOpen, joinTransaction, lock, merge, persist, refresh, remove, setFlushMode
 

Method Detail

query

<T> PagedListData<T> query(PagedListCriteria criteria)
Retrieve a paged query. The query can include a sorting order, which would then be appended to the sort indicated by the page object, if any.

Type Parameters:
T - The type of the result items
Parameters:
criteria - The criteria of the paged query: page index, page size, sorting, etc.
Returns:
The paged result, sorted and paged according to the provided arguments.

find

<T> java.util.List<T> find(java.lang.String queryString,
                           java.lang.Object... params)
Retrieves a non-paged query. Use with care, this method could potentially instantiate large amounts of data.

Type Parameters:
T - The type of the result items
Parameters:
queryString - the query to execute
params - the parameters to be added to the query, in order
Returns:
The result of executing the query

findSingle

<T> T findSingle(java.lang.String queryString,
                 java.lang.Object... params)
Parameters:
queryString - the query to execute
params - the parameters to be added to the query, in order
Returns:
a single object that satisfies the query.
Throws:
javax.persistence.NoResultException - if there is no result
javax.persistence.NonUniqueResultException - if there is more than one result
java.lang.IllegalStateException - if called for a Java Persistence query language UPDATE or DELETE statement

remove

<T> T remove(java.lang.Class<T> clazz,
             java.lang.Object id)
Removes a persistent instance

Type Parameters:
T - The persistent class
Parameters:
clazz - The persistent class
id - the primary key to remove
Returns:
the removed instance
Throws:
EntityNotFoundException - if the entity could not be found

findAll

<T> java.util.List<T> findAll(java.lang.Class<T> clazz)
Retrieves all records for a specified persistent class This method should be used with care, as it could instantiate huge amounts of data.

Type Parameters:
T - The persistent class to retrieve
Parameters:
clazz - The persistent class to retrieve
Returns:
The list of all records found on the database

find

<T> T find(java.lang.Class<T> clazz,
           java.lang.Object id)
Retrieves a single persistent instance from the database

Specified by:
find in interface javax.persistence.EntityManager
Type Parameters:
T - The class to retrieve
Parameters:
clazz - The class to retrieve
id - The primary key to retrieve
Returns:
The retrieved object
Throws:
EntityNotFoundException - if the enity could not be retrieved

findNamed

<T> java.util.List<T> findNamed(java.lang.String namedQuery,
                                java.lang.Object... params)
Retrieves a non-paged query This method should be used with care, as it could instantiate huge amounts of data.

Type Parameters:
T - The type of the result items
Parameters:
namedQuery - the named query to execute
params - the parameters to be added to the query, in order
Returns:
The result of executing the query

findNamedSingle

<T> T findNamedSingle(java.lang.String namedQuery,
                      java.lang.Object... params)
Execute a query that retrieves a single object. This method should be used with care, as it could instantiate huge amounts of data.

Type Parameters:
T - The type of the result items
Parameters:
namedQuery - the named query to execute
params - the parameters to be added to the query, in order
Returns:
a single object that satisfies the named query.
Throws:
javax.persistence.NoResultException - if there is no result
javax.persistence.NonUniqueResultException - if more than one result
java.lang.IllegalStateException - if called for a Java Persistence query language UPDATE or DELETE statement

update

int update(java.lang.String queryString,
           java.lang.Object... params)
Execute a query that updates the database.

Parameters:
queryString - the update/delete/insert query to execute
params - the parameters to be added to the query, in order
Returns:
the number of records that were modified

getIdPropertyName

java.lang.String getIdPropertyName(java.lang.Class<?> clazz)
Parameters:
clazz - the persistent class
Returns:
the name of the id property of a persistent class
Throws:
java.lang.UnsupportedOperationException - if this feature has not been implemented

getVersionPropertyName

java.lang.String getVersionPropertyName(java.lang.Class<?> clazz)
Parameters:
clazz - the persistent class
Returns:
the version property name of a persistent class if it has defined one, null otherwise
Throws:
java.lang.UnsupportedOperationException - if this feature has not been implemented

getVersionValue

<T> T getVersionValue(java.lang.Object entity)
Parameters:
entity - the persistent entity to inspect
Returns:
the version value of a persistent instance, or null if not versioned
Throws:
java.lang.UnsupportedOperationException - if this feature has not been implemented

evict

void evict(java.lang.Object entity)
Remove this instance from the session cache. Changes to the instance will not be synchronized with the database.

Parameters:
entity - a persistent instance

setReadOnly

void setReadOnly(java.lang.Object entity,
                 boolean readOnly)
Sets an instance to readOnly. ReadOnly instances do not write any changes to the database when flushing.

Parameters:
entity - a persistent instance
readOnly - true to set the entity to readOnly