org.lazydog.repository.jpa
Class AbstractRepository

java.lang.Object
  extended by org.lazydog.repository.jpa.AbstractRepository
All Implemented Interfaces:
Repository

public abstract class AbstractRepository
extends Object
implements Repository

Abstract repository implemented using the Java Persistence API.

Author:
Ron Rickard

Constructor Summary
AbstractRepository()
           
 
Method Summary
<T> T
find(Class<T> entityClass, Criteria<T> criteria)
          Find the entity.
protected
<T> T
find(Class<T> entityClass, String queryLanguageString, Map<String,Object> queryParameters, Map<Object,String> queryHints)
          Find the entity.
<T,U> T
find(Class<T> entityClass, U id)
          Find the entity.
<T> List<T>
findList(Class<T> entityClass)
          Find the list of entities.
<T> List<T>
findList(Class<T> entityClass, Criteria<T> criteria)
          Find the list of entities.
protected
<T> List<T>
findList(Class<T> entityClass, String queryLanguageString, Map<String,Object> queryParameters, Map<Object,String> queryHints)
          Find the list of entities.
protected  Connection getConnection()
          Get the connection.
<T> Criteria<T>
getCriteria(Class<T> entityClass)
          Get the criteria.
protected  javax.persistence.EntityManager getEntityManager()
          Get the entity manager.
<T> T
persist(T entity)
          Persist the entity.
<T> List<T>
persistList(List<T> entities)
          Persist the list of entities.
<T,U> void
remove(Class<T> entityClass, U id)
          Remove the entity.
<T,U> void
removeList(Class<T> entityClass, List<U> ids)
          Remove the entities by the list of IDs.
protected  void setEntityManager(javax.persistence.EntityManager entityManager)
          Set the entity manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRepository

public AbstractRepository()
Method Detail

find

public <T,U> T find(Class<T> entityClass,
                    U id)
Find the entity.

Specified by:
find in interface Repository
Parameters:
entityClass - the entity class.
id - the ID.
Returns:
the entity.

find

public <T> T find(Class<T> entityClass,
                  Criteria<T> criteria)
Find the entity.

Specified by:
find in interface Repository
Parameters:
entityClass - the entity class.
criteria - the criteria.
Returns:
the entity.

find

protected <T> T find(Class<T> entityClass,
                     String queryLanguageString,
                     Map<String,Object> queryParameters,
                     Map<Object,String> queryHints)
Find the entity.

Parameters:
entityClass - the entity class.
queryLanguageString - the query language string.
queryParameters - the query parameter map.
queryHints - the query hint map.
Returns:
the entity.

findList

public <T> List<T> findList(Class<T> entityClass)
Find the list of entities.

Specified by:
findList in interface Repository
Parameters:
entityClass - the entity class.
Returns:
the list of entities.

findList

public <T> List<T> findList(Class<T> entityClass,
                            Criteria<T> criteria)
Find the list of entities.

Specified by:
findList in interface Repository
Parameters:
entityClass - the entity class.
criteria - the criteria.
Returns:
the list of entities.

findList

protected <T> List<T> findList(Class<T> entityClass,
                               String queryLanguageString,
                               Map<String,Object> queryParameters,
                               Map<Object,String> queryHints)
Find the list of entities.

Parameters:
entityClass - the entity class.
queryLanguageString - the query language string.
queryParameters - the query parameter map.
queryHints - the query hint map.
Returns:
the list of entities.

getConnection

protected Connection getConnection()
Get the connection.

Returns:
the connection.

getCriteria

public <T> Criteria<T> getCriteria(Class<T> entityClass)
Get the criteria.

Specified by:
getCriteria in interface Repository
Parameters:
entityClass - the entity class.
Returns:
the criteria.

getEntityManager

protected javax.persistence.EntityManager getEntityManager()
Get the entity manager.

Returns:
the entity manager.

persist

public <T> T persist(T entity)
Persist the entity.

Specified by:
persist in interface Repository
Parameters:
entity - the entity.
Returns:
the persisted entity.

persistList

public <T> List<T> persistList(List<T> entities)
Persist the list of entities.

Specified by:
persistList in interface Repository
Parameters:
entities - the entities.
Returns:
the persisted list of entities.

remove

public <T,U> void remove(Class<T> entityClass,
                         U id)
Remove the entity.

Specified by:
remove in interface Repository
Parameters:
entityClass - the entity class.
id - the ID.

removeList

public <T,U> void removeList(Class<T> entityClass,
                             List<U> ids)
Remove the entities by the list of IDs.

Specified by:
removeList in interface Repository
Parameters:
entityClass - the entity class.
ids - the IDs.

setEntityManager

protected void setEntityManager(javax.persistence.EntityManager entityManager)
Set the entity manager.

Parameters:
entityManager - the entity manager.


Copyright © 2013 Lazydog. All Rights Reserved.