|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- Any serializable type, mostly an entity class typeID
- The type of the entity class' unique idpublic 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.
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 |
---|
static final String FIND_ALL
static final String FIND_BY_ID
Method Detail |
---|
T findById(ID id)
id
- Unique technical key to find the entity
List<T> findAll()
List
.
List<T> findByNamedParameters(String queryName, Map<String,?> params)
NamedQuery
and a parameter map.
queryName
- Defined name of the NamedQueryparams
- Map of parameters to pass to the query
List<T> findByPositionalParameters(String queryName, Object... values)
queryName
- Defined name of the NamedQueryvalues
- A list of values to use as parameters
T findByUniqueId(Serializable id)
id
- Natural key to find the entity (also known as business key)
null
T save(T entity)
entity
- Entity instance to be synchronized with the persistence layer
void remove(T entity)
entity
- Entity instance to be removedvoid persist(T entity)
entity
- Entity instance to be persistedvoid setPersistentClass(Class<T> persistentClass)
persistentClass
- Class type of the entity instance
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |