Entity
- Any entity.Key
- Key of the entity.public abstract class AbstractGenericDAO<Entity,Key> extends Object
Constructor and Description |
---|
AbstractGenericDAO() |
Modifier and Type | Method and Description |
---|---|
Collection<Entity> |
getAll(Integer firstResult,
Integer maxResults)
Gets all entities of the kind.
|
Entity |
getByAttribute(String attributeName,
Object attributeValue)
Gets the entity with the given attribute value.
|
Collection<Entity> |
getByAttribute(String attributeName,
Object attributeValue,
Integer firstResult,
Integer maxResults)
Gets all entities with the given attribute value.
|
Entity |
getById(Key identifier)
Gets an entity by its identifier.
|
protected javax.persistence.criteria.CriteriaBuilder |
getCriteriaBuilder()
Gets the criteria builder instance.
|
Class<Entity> |
getEntityClass()
Gets the class of the generic entity.
|
protected abstract javax.persistence.EntityManager |
getEntityManager()
Gets the entity manager for the DAO.
|
protected javax.persistence.Query |
limitResultList(javax.persistence.Query query,
Integer firstResult,
Integer maxResults)
Limit the results of a query.
|
Collection<Entity> |
merge(Collection<Entity> entities)
Merges the entities with the persistence context (so its state is persisted).
|
Entity |
merge(Entity entity)
Merges the entity with the persistence context (so its state is persisted).
|
void |
remove(Collection<Entity> entities)
Removes a persistent entities.
|
void |
remove(Entity entity)
Removes a persistent entity.
|
public Class<Entity> getEntityClass()
protected abstract javax.persistence.EntityManager getEntityManager()
protected javax.persistence.criteria.CriteriaBuilder getCriteriaBuilder()
protected javax.persistence.Query limitResultList(javax.persistence.Query query, Integer firstResult, Integer maxResults)
query
- The query to have its results limited.firstResult
- The first result that should be considered by the query.maxResults
- The maximum numbers of results to be considered by the query.public Entity merge(Entity entity)
entity
- The entity to be merged.public Collection<Entity> merge(Collection<Entity> entities)
entities
- The entities to be merged.public void remove(Entity entity)
entity
- The entity to be persisted.public void remove(Collection<Entity> entities)
entities
- The entities to be persisted.public Entity getById(Key identifier)
identifier
- The identifier of the entity.public Collection<Entity> getByAttribute(String attributeName, Object attributeValue, Integer firstResult, Integer maxResults)
attributeName
- The attribute name.attributeValue
- The attribute value.firstResult
- The first result that should be considered by the query.maxResults
- The maximum numbers of results to be considered by the query.public Entity getByAttribute(String attributeName, Object attributeValue)
attributeName
- The attribute name.attributeValue
- The attribute value.public Collection<Entity> getAll(Integer firstResult, Integer maxResults)
firstResult
- The first result that should be considered by the query.maxResults
- The maximum numbers of results to be considered by the query.Copyright © 2013. All Rights Reserved.