
com.royken.generic.dao.IGenericDao Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of genericDao Show documentation
Show all versions of genericDao Show documentation
A library that provides CRUD and find all methods with JPA
The newest version!
package com.royken.generic.dao;
import java.io.Serializable;
import java.util.List;
/**
*
* @author KENFACK Valmy-Roi
* @param The entity class
* @param The id
*/
public interface IGenericDao {
/**
* Insert the object in the database
* @param newInstance the object to be inserted
* @return the same object
* @throws com.royken.generic.dao.DataAccessException
*/
T create(T newInstance) throws DataAccessException;
/**
* Find in the database the object which id is the parameter
* @param id the id of the object we are searching for
* @return the object with the given id
* @throws com.royken.generic.dao.DataAccessException
*/
T findById(ID id) throws DataAccessException;
/**
* Finds all the occurences of the entity in the database
* @return a list of the given entity
* @throws com.royken.generic.dao.DataAccessException
*/
public List findAll() throws DataAccessException;
/**
* Find all the occurences of the entities in the database between the two given ranges (indexes starts at 0)
* @param begin The starting index range
* @param end The end of the range
* @return a list of the given entity between the range
* @throws com.royken.generic.dao.DataAccessException
*/
public List findRange(int begin, int end) throws DataAccessException;
/**
* Modify an object in the database
* @param transientObject the object with new new attributes
* @return
* @throws com.royken.generic.dao.DataAccessException
*/
T update(T transientObject) throws DataAccessException;
/**
* Delete the given object in the database
* @param persistentObject
* @throws com.royken.generic.dao.DataAccessException
*/
void delete(T persistentObject) throws DataAccessException;
/**
* Gives the number of entitie's occurences in the database
* @return the number of entitie's occurences in the database
* @throws com.royken.generic.dao.DataAccessException
*/
public Long count () throws DataAccessException;
}