Package org.europa.together.business
Interface GenericDAO<T,PK extends Serializable>
- Type Parameters:
T- the entity to savePK- the primary key
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
ConfigurationDAO
- All Known Implementing Classes:
ConfigurationHbmDAO,GenericHbmDAO
@API(status=STABLE,
since="1.0",
consumers="GenrericHbmDAO")
@Component
public interface GenericDAO<T,PK extends Serializable>
extends Serializable
GenericDAO primary for CRUD database operations. To use the DAO by your own
configuration, you need to load the spring-dao.xml into your Spring
context.
A detailed documentation can found at: https://github.com/ElmarDott/TP-CORE/wiki/%5BCORE-02%5D-generic-Data-Access-Object---DAO
A detailed documentation can found at: https://github.com/ElmarDott/TP-CORE/wiki/%5BCORE-02%5D-generic-Data-Access-Object---DAO
- Since:
- 1.0
- Version:
- 1.4
- Author:
- elmar.dott@gmail.com
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlongCount the entries of corresponding table to the domain object is specialized in the DAO.booleanPersist a new entity and return TRUE if it was successful.In the case that the entity is already existing or the persist project is not a valid entity the method return FALSE.voidSearch for an persistent entity.If it's already existent then it will be delete, otherwise a EntityNotFoundException will thrown.deserializeJsonAsList(String json) Tries to create from a collection of JSON objects a list of enties.Tried to create a entity object from a given JSON String.deserializeJsonAsObject(String json, Class<T> object) Deprecated.Try to find a persited domain object.getPrimaryKeyOfObject(T object) Get the primary key of the DAO entity.listAllElements(JpaPagination seekElement) Get all persited entries of an entity as list.serializeAsJson(T object) Check if the entity is not NULL and try to create a JSON object as String, otherwise the String will be empty.voidSearch an entity in the persistence context and update it.If it's not exist a EntityNotFoundException will thrown.
-
Field Details
-
FEATURE_ID
Identifier for the given feature.- See Also:
-
-
Method Details
-
create
Persist a new entity and return TRUE if it was successful.In the case that the entity is already existing or the persist project is not a valid entity the method return FALSE.- Parameters:
object- as Generic- Returns:
- true on success
- Throws:
DAOException- in case of error
-
delete
Search for an persistent entity.If it's already existent then it will be delete, otherwise a EntityNotFoundException will thrown.- Parameters:
id- as Generic- Throws:
DAOException- in case of error
-
update
Search an entity in the persistence context and update it.If it's not exist a EntityNotFoundException will thrown.- Parameters:
id- as Genericobject- as Generic- Throws:
DAOException- in case of error
-
countAllElements
@API(status=STABLE, since="3.0") long countAllElements()Count the entries of corresponding table to the domain object is specialized in the DAO.- Returns:
- count as long
-
listAllElements
Get all persited entries of an entity as list.- Parameters:
seekElement- as JpaPagination- Returns:
- List of Entity Objects
-
getPrimaryKeyOfObject
Get the primary key of the DAO entity.- Parameters:
object- as Genric- Returns:
- id as Genric
-
serializeAsJson
Check if the entity is not NULL and try to create a JSON object as String, otherwise the String will be empty.- Parameters:
object- as Generic- Returns:
- JSON object as String
- Throws:
JsonProcessingException- in case of error
-
deserializeJsonAsObject
@API(status=DEPRECATED, since="2.1") @Deprecated T deserializeJsonAsObject(String json, Class<T> object) throws JsonProcessingException, ClassNotFoundException Deprecated.Tried to create a entity object from a given JSON String.- Parameters:
json- as Stringobject- as T- Returns:
- Entity as Generic
- Throws:
JsonProcessingException- in case of errorClassNotFoundException- in case of error
-
deserializeJsonAsObject
@API(status=STABLE, since="3.2") T deserializeJsonAsObject(String json) throws JsonProcessingException, ClassNotFoundException Tried to create a entity object from a given JSON String.- Parameters:
json- as String- Returns:
- Entity as Generic
- Throws:
JsonProcessingException- in case of errorClassNotFoundException- in case of error
-
deserializeJsonAsList
@API(status=STABLE, since="3.0") List<T> deserializeJsonAsList(String json) throws JsonProcessingException, ClassNotFoundException Tries to create from a collection of JSON objects a list of enties.- Parameters:
json- as String- Returns:
- List of Entities
- Throws:
JsonProcessingException- in case of errorClassNotFoundException- in case of error
-
find
Try to find a persited domain object.- Parameters:
id- as Generic- Returns:
- object as Generic
-