org.openwms.core.integration
Interface GenericDao<T extends AbstractEntity,ID extends Serializable>

Type Parameters:
T - Any serializable type, mostly an entity class type
ID - The type of the entity class' unique id
All Known Subinterfaces:
I18nRepository, LocationDao, LocationGroupDao, LocationTypeDao, ModuleDao, RoleDao, TransportOrderDao, TransportUnitDao, TransportUnitTypeDao, UserDao
All Known Implementing Classes:
AbstractGenericJpaDao, GenericJpaDaoImpl, I18nRepositoryImpl, LocationDaoImpl, LocationGroupDaoImpl, LocationTypeDaoImpl, ModuleDaoImpl, RoleDaoImpl, TransportOrderDaoImpl, TransportUnitDaoImpl, TransportUnitTypeDaoImpl, UserDaoImpl

public interface GenericDao<T extends AbstractEntity,ID extends Serializable>

A GenericDao is a generic interface declaration that defines simple CRUD operations.

This interface provides basic functionality to create/read/update and delete entity classes. Entities can be simple POJO classes without any ORM dependencies. Merely implementations of this interface knows about the way the entity is been persisted.

Since:
0.1
Version:
$Revision: 1540 $
Author:
Heiko Scherrer

Field Summary
static String FIND_ALL
          Suffix for the FIND_ALL named query.
static String FIND_BY_ID
          Suffix for the FIND_BY_ID named query.
 
Method Summary
 List<T> findAll()
          Find all entities and return them as a List.
 T findById(ID id)
          Find and return the entity identified by the technical key.
 List<T> findByNamedParameters(String queryName, Map<String,?> params)
          Use a named query to find all entities.
 List<T> findByPositionalParameters(String queryName, Object... values)
          Use an own JPA query to fetch entities.
 T findByUniqueId(Serializable id)
          Find and return the entity identified by the natural unique id.
 void persist(T entity)
          Persist a transient entity.
 void remove(T entity)
          Removes an already persistent entity.
 T save(T entity)
          Synchronize an entity with the persistence layer and return it.
 void setPersistentClass(Class<T> persistentClass)
          Set the type of entity to deal with.
 

Field Detail

FIND_ALL

static final String FIND_ALL
Suffix for the FIND_ALL named query.

See Also:
Constant Field Values

FIND_BY_ID

static final String FIND_BY_ID
Suffix for the FIND_BY_ID named query.

See Also:
Constant Field Values
Method Detail

findById

T findById(ID id)
Find and return the entity identified by the technical key.

Parameters:
id - Unique technical key to find the entity
Returns:
Entity class identified by id

findAll

List<T> findAll()
Find all entities and return them as a List.

Returns:
List of all entities

findByNamedParameters

List<T> findByNamedParameters(String queryName,
                              Map<String,?> params)
Use a named query to find all entities. Pass in the name of the NamedQuery and a parameter map.

Parameters:
queryName - Defined name of the NamedQuery
params - Map of parameters to pass to the query
Returns:
List of found entity classes

findByPositionalParameters

List<T> findByPositionalParameters(String queryName,
                                   Object... values)
Use an own JPA query to fetch entities.

Parameters:
queryName - Defined name of the NamedQuery
values - A list of values to use as parameters
Returns:
A list of all entities

findByUniqueId

T findByUniqueId(Serializable id)
Find and return the entity identified by the natural unique id.

Parameters:
id - Natural key to find the entity (also known as business key)
Returns:
The entity or null

save

T save(T entity)
Synchronize an entity with the persistence layer and return it.

Parameters:
entity - Entity instance to be synchronized with the persistence layer
Returns:
The synchronized entity instance. If JPA is used as implementation, the returned instance is managed.

remove

void remove(T entity)
Removes an already persistent entity.

Parameters:
entity - Entity instance to be removed

persist

void persist(T entity)
Persist a transient entity.

Parameters:
entity - Entity instance to be persisted

setPersistentClass

void setPersistentClass(Class<T> persistentClass)
Set the type of entity to deal with.

Parameters:
persistentClass - Class type of the entity instance


Copyright © 2005-2011 openwms.org. All Rights Reserved.