net.sf.derquinsej.hib3
Class RepositoryImpl

java.lang.Object
  extended by net.sf.derquinsej.hib3.AbstractDAOImpl
      extended by net.sf.derquinsej.hib3.GeneralDAOImpl
          extended by net.sf.derquinsej.hib3.RepositoryImpl
All Implemented Interfaces:
DAO, GeneralDAO, Repository

public class RepositoryImpl
extends GeneralDAOImpl
implements Repository

Implementation of the General DAO.

Author:
Andres Rodriguez

Constructor Summary
RepositoryImpl()
          Constructs the DAO
RepositoryImpl(org.hibernate.SessionFactory sessionFactory)
          Constructs the DAO
 
Method Summary
 void evict(Object object)
          Remove the provided instance from the session cache.
<T> T
first(Class<T> type, org.hibernate.Query query)
          Returns the first result of a query returning instances of a specified class.
 org.hibernate.Query getNamedQuery(String queryName)
          Returns a externally defined named query.
<T> List<T>
list(Class<T> type, org.hibernate.Query query)
          Returns the results of a query as a list of a specified class.
<T> List<T>
list(Class<T> type, String queryName, Object value)
          Returns the results of a named query with a single parameter as a list of a specified class.
<T> T
unique(Class<T> type, org.hibernate.Query query)
          Returns the unique result of a query returning instances of a specified class.
<T> T
unique(Class<T> type, String queryName, Object value)
          Returns the unique result of a named query with a single parameter returning instances of a specified class.
 
Methods inherited from class net.sf.derquinsej.hib3.GeneralDAOImpl
delete, deleteById, findAll, findByCriteria, findById, newCriteria, save, saveOrUpdate, update
 
Methods inherited from class net.sf.derquinsej.hib3.AbstractDAOImpl
clear, flush, getSession, setSessionFactory, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.derquinsej.hib3.Repository
delete, deleteById, findAll, findById, save, saveOrUpdate, update
 
Methods inherited from interface net.sf.derquinsej.hib3.DAO
clear, flush, sync
 

Constructor Detail

RepositoryImpl

public RepositoryImpl(org.hibernate.SessionFactory sessionFactory)
Constructs the DAO

Parameters:
sessionFactory - Hibernate Session factory.

RepositoryImpl

public RepositoryImpl()
Constructs the DAO

Method Detail

evict

public void evict(Object object)
Description copied from class: AbstractDAOImpl
Remove the provided instance from the session cache.

Specified by:
evict in interface Repository
Overrides:
evict in class AbstractDAOImpl
Parameters:
object - The persistent instance to remove.

first

public <T> T first(Class<T> type,
                   org.hibernate.Query query)
Description copied from class: AbstractDAOImpl
Returns the first result of a query returning instances of a specified class.

Specified by:
first in interface Repository
Overrides:
first in class AbstractDAOImpl
Parameters:
type - Entity type.
query - Query to execute.
Returns:
The first result or null if there are no results.

getNamedQuery

public org.hibernate.Query getNamedQuery(String queryName)
Description copied from class: AbstractDAOImpl
Returns a externally defined named query.

Specified by:
getNamedQuery in interface Repository
Overrides:
getNamedQuery in class AbstractDAOImpl
Parameters:
queryName - Query name.
Returns:
The requested query.

list

public <T> List<T> list(Class<T> type,
                        org.hibernate.Query query)
Description copied from class: AbstractDAOImpl
Returns the results of a query as a list of a specified class.

Specified by:
list in interface Repository
Overrides:
list in class AbstractDAOImpl
Parameters:
type - Entity type.
query - Query to execute.
Returns:
The results.

list

public <T> List<T> list(Class<T> type,
                        String queryName,
                        Object value)
Description copied from class: AbstractDAOImpl
Returns the results of a named query with a single parameter as a list of a specified class.

Specified by:
list in interface Repository
Overrides:
list in class AbstractDAOImpl
Parameters:
type - Entity type.
queryName - Query name.
value - Non-null parameter value.
Returns:
The results.

unique

public <T> T unique(Class<T> type,
                    org.hibernate.Query query)
Description copied from class: AbstractDAOImpl
Returns the unique result of a query returning instances of a specified class.

Specified by:
unique in interface Repository
Overrides:
unique in class AbstractDAOImpl
Parameters:
type - Entity type.
query - Query to execute.
Returns:
The unique result or null if there are no results.

unique

public <T> T unique(Class<T> type,
                    String queryName,
                    Object value)
Description copied from class: AbstractDAOImpl
Returns the unique result of a named query with a single parameter returning instances of a specified class.

Specified by:
unique in interface Repository
Overrides:
unique in class AbstractDAOImpl
Parameters:
type - Entity type.
queryName - Query name.
value - Non-null parameter value.
Returns:
The unique result or null if there are no results.


Copyright © 2011. All Rights Reserved.