Interface TopiaJpaSupport
- All Known Implementing Classes:
HibernateTopiaJpaSupport
public interface TopiaJpaSupport
This API provides methods to use persistence using JPA queries
- Since:
- 3.0
- Author:
- Arnaud Thimel (Code Lutin)
-
Method Summary
Modifier and TypeMethodDescriptionvoidRemove a persistent instance.intExecute JPA-QL operation on data (Update, Delete).<T> List<T>Allow to do some JPA-QL query using the given bounds.<T> List<T>Allow to do some JPA-QL query WARNING : Depending on the registered service, this method may not support something else than queries on TopiaEntity<T> TAllow to do some JPA-QL query and return a single result.<T> TfindUnique(String jpaql, Map<String, Object> parameters) Allow to do some JPA-QL query and return an unique result.voidPersist the given transient instance, first assigning a generated identifier.voidsaveOrUpdate(Object object) Eithersave(Object)orupdate(Object)the given instance.voidsetSlowQueriesThreshold(Duration threshold) Tells to the context after which delay a query should be considered as slow.voidsetUseFlushMode(boolean useFlushMode) Tells to the context if it has to use a flush mode before each query.default <T> Stream<T>Streaming on the result of afindAll(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>).voidUpdate the persistent instance with the identifier of the given detached instance.
-
Method Details
-
findAll
Allow to do some JPA-QL query WARNING : Depending on the registered service, this method may not support something else than queries on TopiaEntity- Type Parameters:
T- type of result- Parameters:
jpaql- the JPA-QL queryparameters- a map which keys are the attribute names and values are the attributes expected values- Returns:
- The result list
-
stream
Streaming on the result of afindAll(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>). Streaming is not part of JPA but may be part a JPA implementation so we provide a default implementation that will work on any JPA vendor.- Since:
- 3.4
-
find
<T> List<T> find(String jpaql, int startIndex, int endIndex, Map<String, Object> parameters) throws QueryMissingOrderExceptionAllow to do some JPA-QL query using the given bounds.- No lower bound :
startIndex = 0. - No upper bound :
endIndex = -1.
- Type Parameters:
T- type of result- Parameters:
jpaql- the JPA-QL querystartIndex- first index of entity to returnendIndex- last index of entity to returnparameters- a map which keys are the attribute names and values are the attributes expected values- Returns:
- The result list
- Throws:
QueryMissingOrderException- if no order by clause is specified
- No lower bound :
-
findAny
Allow to do some JPA-QL query and return a single result. If nothing is found by the query, will return null. WARNING : Depending on the registered service, this method may not support something else than queries on TopiaEntity- Type Parameters:
T- type of result- Parameters:
jpaql- the JPA-QL queryparameters- a map which keys are the attribute names and values are the attributes expected values- Returns:
- The result instance or null
-
findUnique
Allow to do some JPA-QL query and return an unique result. If nothing is found by the query, will return null. If more than one result is found, will throw an exception. WARNING : Depending on the registered service, this method may not support something else than queries on TopiaEntity- Type Parameters:
T- type of result- Parameters:
jpaql- the JPA-QL queryparameters- a map which keys are the attribute names and values are the attributes expected values- Returns:
- The result instance or null
-
execute
Execute JPA-QL operation on data (Update, Delete).- Parameters:
jpaql- the JPA-QL queryparameters- a map which keys are the attribute names and values are the attributes expected values- Returns:
- The number of entities updated or deleted.
-
setUseFlushMode
void setUseFlushMode(boolean useFlushMode) Tells to the context if it has to use a flush mode before each query. By default, we use a flush mode, but in some case it costs to much doing this, that's why you can disable it setting the value tofalse.- Parameters:
useFlushMode- the new value to set- Since:
- 2.5
-
setSlowQueriesThreshold
Tells to the context after which delay a query should be considered as slow. Default value is to skip slow queries watching unless specified in application configuration.- Parameters:
threshold- the new value to set- Since:
- 3.8
-
save
Persist the given transient instance, first assigning a generated identifier. This method is JPA implementation independent. This method is "inspired" of the Hibernate's Session#save method.- Parameters:
object- a transient instance of a persistent class
-
update
Update the persistent instance with the identifier of the given detached instance. This method is "inspired" of the Hibernate's Session#update method.- Parameters:
object- a detached instance containing updated state
-
saveOrUpdate
Eithersave(Object)orupdate(Object)the given instance. This method is "inspired" of the Hibernate's Session#saveOrUpdate method.- Parameters:
object- a transient or detached instance containing new or updated state- See Also:
-
delete
Remove a persistent instance. This method is "inspired" of the Hibernate's Session#delete method.- Parameters:
object- the instance to be removed
-