Package com.linkare.commons.dao
Interface IGenericDAO<Entity extends Identifiable<ID> & Deletable,ID extends Serializable>
-
- Type Parameters:
Entity- The entity type to which this generic dao presents an interface.ID- The identifier type of theEntitytype.
public interface IGenericDAO<Entity extends Identifiable<ID> & Deletable,ID extends Serializable>This interface presents the common set of operations that any DAO should provide by default. Possible implementations of this interface are DAOs for JPA access or JDBC.- Author:
- Paulo Zenida - Linkare TI
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcount()Provides the count operation for the list of entities found.voidcreate(Entity entity)Provides the create/persist operation for theentitypassed in.Entityedit(Entity entity)Provides the edit/merge operation for theentitypassed in.List<Entity>find(boolean all, int firstResult, int maxResults)Provides the find operation, allowing pagination of results.Entityfind(ID id)Provides the find operation, based on the entity'sid.List<Entity>findAll()Provides the find all operation.List<Entity>findRange(int[] range)Provides the find operation, according to a range of results.voidremove(Entity entity)Provides the remove operation for theentitypassed in.
-
-
-
Method Detail
-
create
void create(Entity entity)
Provides the create/persist operation for theentitypassed in.- Parameters:
entity- the entity to create.
-
edit
Entity edit(Entity entity)
Provides the edit/merge operation for theentitypassed in.- Parameters:
entity- the entity to edit.- Returns:
- Returns the entity after being merged/updated.
-
remove
void remove(Entity entity)
Provides the remove operation for theentitypassed in.- Parameters:
entity- the entity to remove.
-
find
Entity find(ID id)
Provides the find operation, based on the entity'sid.- Parameters:
id- the id to be found.- Returns:
- Returns the entity if found. It returns null otherwise.
-
find
List<Entity> find(boolean all, int firstResult, int maxResults)
Provides the find operation, allowing pagination of results.- Parameters:
all- flag to control if the method should look for all entities.firstResult- the number where the result query should start.maxResults- the maximum number of entities afterfirstResultthat this method should return.- Returns:
- Returns the list of entities found.
-
findRange
List<Entity> findRange(int[] range)
Provides the find operation, according to a range of results.- Parameters:
range- the range to look for in the resulting list.- Returns:
- Returns the list of entities found in the determined
range.
-
findAll
List<Entity> findAll()
Provides the find all operation.- Returns:
- Returns the full list of entities found.
-
count
int count()
Provides the count operation for the list of entities found.- Returns:
- Returns the number of entities found.
-
-