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
-
Method Summary
Modifier and TypeMethodDescriptionlong
Count the entries of corresponding table to the domain object is specialized in the DAO.boolean
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.void
Search 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.deserializeJsonAsObject
(String json, Class<T> object) Tried to create a entity object from a given JSON String.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.void
Search 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
-
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
-
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
-
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
com.fasterxml.jackson.core.JsonProcessingException
-
deserializeJsonAsObject
@API(status=STABLE, since="2.1") T deserializeJsonAsObject(String json, Class<T> object) throws JsonProcessingException, ClassNotFoundException Tried to create a entity object from a given JSON String.- Parameters:
json
- as Stringobject
- as T- Returns:
- Entity as Generic
- Throws:
JsonProcessingException
ClassNotFoundException
-
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
ClassNotFoundException
-
find
Try to find a persited domain object.- Parameters:
id
- as Generic- Returns:
- object as Generic
-