org.synyx.hades.dao.orm
Class GenericDaoFactory

java.lang.Object
  extended by org.synyx.hades.dao.orm.GenericDaoFactory
Direct Known Subclasses:
GenericDaoFactoryBean

public class GenericDaoFactory
extends java.lang.Object

Factory bean to create instances of a given DAO interface. Creates a proxy implementing the configured DAO interface and apply an advice handing the control to the FinderExecuterMethodInterceptor when a method beginning with the configured finder prefix is called. This defaults to . Furthermore finder resolution can be configured by setting queryLookupStrategy which defaults to QueryLookupStrategy.getDefault()

Author:
Oliver Gierke

Constructor Summary
protected GenericDaoFactory()
          Protected constructor to prevent simple construction from clients.
 
Method Summary
static GenericDaoFactory create(javax.persistence.EntityManager entityManager)
          Creates a new GenericDaoFactory with the given EntityManager.
<T extends GenericDao<?,?>>
T
getDao(java.lang.Class<T> daoInterface)
          Returns a DAO instance for the given interface.
<T extends GenericDao<?,?>>
T
getDao(java.lang.Class<T> daoInterface, java.lang.Object customDaoImplementation)
          Returns a DAO instance for the given interface backed by an instance providing implementation logic for custom logic.
protected  java.lang.Class<? extends GenericDaoSupport> getDaoClass()
          Determines the base class for the DAO to be created by checking the EntityManager's concrete type.
protected  javax.persistence.EntityManager getEntityManager()
          Returns the EntityManager.
 void setEntityManager(javax.persistence.EntityManager entityManager)
          Setter to inject entity manager.
 void setQueryLookupStrategy(QueryLookupStrategy queryLookupStrategy)
          Sets the strategy of how to lookup a query to execute finders.
protected  void validate(java.lang.Class<? extends GenericDao<?,?>> daoInterface, java.lang.Object customDaoImplementation)
          Validates the given DAO interface as well as the given custom implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericDaoFactory

protected GenericDaoFactory()
Protected constructor to prevent simple construction from clients.

Method Detail

create

public static GenericDaoFactory create(javax.persistence.EntityManager entityManager)
Creates a new GenericDaoFactory with the given EntityManager.

Parameters:
entityManager -
Returns:

getEntityManager

protected javax.persistence.EntityManager getEntityManager()
Returns the EntityManager.

Returns:
the entityManager

setEntityManager

public void setEntityManager(javax.persistence.EntityManager entityManager)
Setter to inject entity manager.

Parameters:
entityManager - the EntityManager to set

setQueryLookupStrategy

public void setQueryLookupStrategy(QueryLookupStrategy queryLookupStrategy)
Sets the strategy of how to lookup a query to execute finders.

Parameters:
queryLookupStrategy - the createFinderQueries to set

getDao

public <T extends GenericDao<?,?>> T getDao(java.lang.Class<T> daoInterface)
Returns a DAO instance for the given interface.

Type Parameters:
T -
Parameters:
daoInterface -
Returns:

getDao

public <T extends GenericDao<?,?>> T getDao(java.lang.Class<T> daoInterface,
                                            java.lang.Object customDaoImplementation)
Returns a DAO instance for the given interface backed by an instance providing implementation logic for custom logic.

Type Parameters:
T -
Parameters:
daoInterface -
customDaoImplementation -
Returns:

getDaoClass

protected java.lang.Class<? extends GenericDaoSupport> getDaoClass()
Determines the base class for the DAO to be created by checking the EntityManager's concrete type. If no well known type can be detected #DEFAULT_DAO_CLASS will be returned.

Protected to eventually customize base class - see #102 for details.

Returns:

validate

protected void validate(java.lang.Class<? extends GenericDao<?,?>> daoInterface,
                        java.lang.Object customDaoImplementation)
Validates the given DAO interface as well as the given custom implementation.

Parameters:
daoInterface -
customDaoImplementation -


Copyright © 2009-2010 Synyx GmbH & Co. KG. All Rights Reserved.