org.loom.persistence
Class AbstractExtendedEntityManagerOperations

java.lang.Object
  extended by org.loom.persistence.AbstractExtendedEntityManagerOperations
All Implemented Interfaces:
ExtendedEntityManagerOperations, org.springframework.orm.jpa.EntityManagerPlusOperations
Direct Known Subclasses:
HibernateEntityManagerOperations

public abstract class AbstractExtendedEntityManagerOperations
extends java.lang.Object
implements ExtendedEntityManagerOperations

Default implementation of the extended operations

Author:
icoloma

Constructor Summary
AbstractExtendedEntityManagerOperations(javax.persistence.EntityManager entityManager)
           
 
Method Summary
<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)
           
 javax.persistence.EntityManager getEntityManager()
           
<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
 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.ExtendedEntityManagerOperations
evict, getIdPropertyName, getVersionPropertyName, getVersionValue, setReadOnly
 

Constructor Detail

AbstractExtendedEntityManagerOperations

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

query

public <T> PagedListData<T> query(PagedListCriteria criteria)
Description copied from interface: ExtendedEntityManagerOperations
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 ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
Retrieves a non-paged query. Use with care, this method could potentially instantiate large amounts of data.

Specified by:
find in interface ExtendedEntityManagerOperations
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 ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
Removes a persistent instance

Specified by:
remove in interface ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
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 ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
Retrieves a single persistent instance from the database

Specified by:
find in interface ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
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 ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
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 ExtendedEntityManagerOperations
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: ExtendedEntityManagerOperations
Execute a query that updates the database.

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

getEntityManager

public javax.persistence.EntityManager getEntityManager()


The Loom Framework 1.6-SNAPSHOT.
Licensed under the Apache License, Version 2.0 by Extrema Sistemas de Informacion S.L.