org.loom.persistence
Class AbstractExtendedEntityManager

java.lang.Object
  extended by org.loom.persistence.AbstractExtendedEntityManager
All Implemented Interfaces:
javax.persistence.EntityManager, ExtendedEntityManager
Direct Known Subclasses:
HibernateExtendedEntityManagerImpl

public abstract class AbstractExtendedEntityManager
extends java.lang.Object
implements ExtendedEntityManager

Default implementation of the extended operations


Constructor Summary
AbstractExtendedEntityManager(javax.persistence.EntityManager entityManager)
           
 
Method Summary
 void clear()
           
 void close()
           
 boolean contains(java.lang.Object entity)
           
 javax.persistence.Query createNamedQuery(java.lang.String name)
           
 javax.persistence.Query createNativeQuery(java.lang.String sqlString)
           
 javax.persistence.Query createNativeQuery(java.lang.String sqlString, java.lang.Class resultClass)
           
 javax.persistence.Query createNativeQuery(java.lang.String sqlString, java.lang.String resultSetMapping)
           
 javax.persistence.Query createQuery(java.lang.String qlString)
           
<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)
           
 void flush()
           
 java.lang.Object getDelegate()
           
 javax.persistence.EntityManager getEntityManager()
           
 javax.persistence.FlushModeType getFlushMode()
           
<T> T
getReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey)
           
 javax.persistence.EntityTransaction getTransaction()
           
 boolean isOpen()
           
 void joinTransaction()
           
 void lock(java.lang.Object entity, javax.persistence.LockModeType lockMode)
           
<T> T
merge(T entity)
           
 void persist(java.lang.Object entity)
           
<T> PagedListData<T>
query(PagedListCriteria criteria)
          Retrieve a paged query.
 void refresh(java.lang.Object entity)
           
<T> T
remove(java.lang.Class<T> clazz, java.lang.Object id)
          Removes a persistent instance
 void remove(java.lang.Object entity)
           
 void setFlushMode(javax.persistence.FlushModeType flushMode)
           
 int update(java.lang.String queryString, java.lang.Object... params)
          Execute a query that updates the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.loom.persistence.ExtendedEntityManager
evict, getIdPropertyName, getVersionPropertyName, getVersionValue, setReadOnly
 

Constructor Detail

AbstractExtendedEntityManager

public AbstractExtendedEntityManager(javax.persistence.EntityManager entityManager)
Method Detail

query

public <T> PagedListData<T> query(PagedListCriteria criteria)
Description copied from interface: ExtendedEntityManager
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.

Specified by:
query in interface ExtendedEntityManager
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

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

Specified by:
find in interface ExtendedEntityManager
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

public <T> T findSingle(java.lang.String queryString,
                        java.lang.Object... params)
Specified by:
findSingle in interface ExtendedEntityManager
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.

remove

public <T> T remove(java.lang.Class<T> clazz,
                    java.lang.Object id)
Description copied from interface: ExtendedEntityManager
Removes a persistent instance

Specified by:
remove in interface ExtendedEntityManager
Type Parameters:
T - The persistent class
Parameters:
clazz - The persistent class
id - the primary key to remove
Returns:
the removed instance

findAll

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

Specified by:
findAll in interface ExtendedEntityManager
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

public <T> T find(java.lang.Class<T> clazz,
                  java.lang.Object id)
Description copied from interface: ExtendedEntityManager
Retrieves a single persistent instance from the database

Specified by:
find in interface javax.persistence.EntityManager
Specified by:
find in interface ExtendedEntityManager
Type Parameters:
T - The class to retrieve
Parameters:
clazz - The class to retrieve
id - The primary key to retrieve
Returns:
The retrieved object

findNamed

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

Specified by:
findNamed in interface ExtendedEntityManager
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

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

Specified by:
findNamedSingle in interface ExtendedEntityManager
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.

update

public int update(java.lang.String queryString,
                  java.lang.Object... params)
Description copied from interface: ExtendedEntityManager
Execute a query that updates the database.

Specified by:
update in interface ExtendedEntityManager
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

remove

public void remove(java.lang.Object entity)
Specified by:
remove in interface javax.persistence.EntityManager

clear

public void clear()
Specified by:
clear in interface javax.persistence.EntityManager

close

public void close()
Specified by:
close in interface javax.persistence.EntityManager

contains

public boolean contains(java.lang.Object entity)
Specified by:
contains in interface javax.persistence.EntityManager

createNamedQuery

public javax.persistence.Query createNamedQuery(java.lang.String name)
Specified by:
createNamedQuery in interface javax.persistence.EntityManager

createNativeQuery

public javax.persistence.Query createNativeQuery(java.lang.String sqlString,
                                                 java.lang.Class resultClass)
Specified by:
createNativeQuery in interface javax.persistence.EntityManager

createNativeQuery

public javax.persistence.Query createNativeQuery(java.lang.String sqlString,
                                                 java.lang.String resultSetMapping)
Specified by:
createNativeQuery in interface javax.persistence.EntityManager

createNativeQuery

public javax.persistence.Query createNativeQuery(java.lang.String sqlString)
Specified by:
createNativeQuery in interface javax.persistence.EntityManager

createQuery

public javax.persistence.Query createQuery(java.lang.String qlString)
Specified by:
createQuery in interface javax.persistence.EntityManager

flush

public void flush()
Specified by:
flush in interface javax.persistence.EntityManager

getDelegate

public java.lang.Object getDelegate()
Specified by:
getDelegate in interface javax.persistence.EntityManager

getFlushMode

public javax.persistence.FlushModeType getFlushMode()
Specified by:
getFlushMode in interface javax.persistence.EntityManager

getReference

public <T> T getReference(java.lang.Class<T> entityClass,
                          java.lang.Object primaryKey)
Specified by:
getReference in interface javax.persistence.EntityManager

getTransaction

public javax.persistence.EntityTransaction getTransaction()
Specified by:
getTransaction in interface javax.persistence.EntityManager

isOpen

public boolean isOpen()
Specified by:
isOpen in interface javax.persistence.EntityManager

joinTransaction

public void joinTransaction()
Specified by:
joinTransaction in interface javax.persistence.EntityManager

lock

public void lock(java.lang.Object entity,
                 javax.persistence.LockModeType lockMode)
Specified by:
lock in interface javax.persistence.EntityManager

merge

public <T> T merge(T entity)
Specified by:
merge in interface javax.persistence.EntityManager

persist

public void persist(java.lang.Object entity)
Specified by:
persist in interface javax.persistence.EntityManager

refresh

public void refresh(java.lang.Object entity)
Specified by:
refresh in interface javax.persistence.EntityManager

setFlushMode

public void setFlushMode(javax.persistence.FlushModeType flushMode)
Specified by:
setFlushMode in interface javax.persistence.EntityManager

getEntityManager

public javax.persistence.EntityManager getEntityManager()