net.sf.derquinsej.hib3
Interface Repository

All Superinterfaces:
DAO, GeneralDAO
All Known Implementing Classes:
RepositoryImpl

public interface Repository
extends GeneralDAO

Repository interface, in case the DAO pattern isn't applied.

Author:
Andres Rodriguez

Method Summary
 void delete(Object entity)
          Deletes an entity instance.
<T> void
deleteById(Class<T> type, Serializable id)
          Deletes an entity instance.
 void evict(Object object)
          Remove the provided instance from the session cache.
<T> List<T>
findAll(Class<T> type)
          Returns all entities of the persistent type.
<T> T
findById(Class<T> type, Serializable id, boolean lock)
          Finds an entity by ID.
<T> T
first(Class<T> type, Query query)
          Returns the first result of a query returning instances of a specified class.
 Query getNamedQuery(String queryName)
          Returns a externally defined named query.
<T> List<T>
list(Class<T> type, 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.
 void save(Object entity)
          Saves an entity.
 void saveOrUpdate(Object entity)
          Saves or updates an entity, depending upon resolution of the unsaved-value checks.
<T> T
unique(Class<T> type, 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.
 void update(Object entity)
          Updates an entity.
 
Methods inherited from interface net.sf.derquinsej.hib3.DAO
clear, flush, sync
 

Method Detail

findById

<T> T findById(Class<T> type,
               Serializable id,
               boolean lock)
Finds an entity by ID.

Specified by:
findById in interface GeneralDAO
Parameters:
type - Entity type.
id - ID.
lock - If the entity shall be locked.
Returns:
The requested entity or null if it is not found.

findAll

<T> List<T> findAll(Class<T> type)
Returns all entities of the persistent type.

Specified by:
findAll in interface GeneralDAO
Parameters:
type - Entity type.
Returns:
A list with all the instances.

save

void save(Object entity)
Saves an entity.

Specified by:
save in interface GeneralDAO
Parameters:
entity - Entity to save.

update

void update(Object entity)
Updates an entity.

Specified by:
update in interface GeneralDAO
Parameters:
entity - Entity to update.

saveOrUpdate

void saveOrUpdate(Object entity)
Saves or updates an entity, depending upon resolution of the unsaved-value checks.

Specified by:
saveOrUpdate in interface GeneralDAO
Parameters:
entity - Entity to persist.

delete

void delete(Object entity)
Deletes an entity instance.

Specified by:
delete in interface GeneralDAO
Parameters:
entity - Instance to delete.

deleteById

<T> void deleteById(Class<T> type,
                    Serializable id)
Deletes an entity instance.

Specified by:
deleteById in interface GeneralDAO
Parameters:
type - Entity type.
id - Id of the instance to delete.

evict

void evict(Object object)
Remove the provided instance from the session cache.

Parameters:
object - The persistent instance to remove.

getNamedQuery

Query getNamedQuery(String queryName)
Returns a externally defined named query.

Parameters:
queryName - Query name.
Returns:
The requested query.

list

<T> List<T> list(Class<T> type,
                 Query query)
Returns the results of a query as a list of a specified class.

Parameters:
type - Entity type.
query - Query to execute.
Returns:
The results.

first

<T> T first(Class<T> type,
            Query query)
Returns the first result of a query returning instances of a specified class.

Parameters:
type - Entity type.
query - Query to execute.
Returns:
The first result or null if there are no results.

unique

<T> T unique(Class<T> type,
             Query query)
Returns the unique result of a query returning instances of a specified class.

Parameters:
type - Entity type.
query - Query to execute.
Returns:
The unique result or null if there are no results.
Throws:
NonUniqueResultException - if there are more than one result.

list

<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.

Parameters:
type - Entity type.
queryName - Query name.
value - Non-null parameter value.
Returns:
The results.

unique

<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.

Parameters:
type - Entity type.
queryName - Query name.
value - Non-null parameter value.
Returns:
The unique result or null if there are no results.
Throws:
NonUniqueResultException - if there are more than one result.


Copyright © 2012. All Rights Reserved.