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 Details

    • findAll

      <T> List<T> findAll(String jpaql, Map<String,Object> parameters)
      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 query
      parameters - a map which keys are the attribute names and values are the attributes expected values
      Returns:
      The result list
    • stream

      default <T> Stream<T> stream(String jpaql, Map<String,Object> parameters)
      Streaming on the result of a findAll(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 QueryMissingOrderException
      Allow to do some JPA-QL query using the given bounds.
      • No lower bound : startIndex = 0.
      • No upper bound : endIndex = -1.
      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 query
      startIndex - first index of entity to return
      endIndex - last index of entity to return
      parameters - 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
    • findAny

      <T> T findAny(String jpaql, Map<String,Object> parameters)
      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 query
      parameters - a map which keys are the attribute names and values are the attributes expected values
      Returns:
      The result instance or null
    • findUnique

      <T> T findUnique(String jpaql, Map<String,Object> parameters)
      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 query
      parameters - a map which keys are the attribute names and values are the attributes expected values
      Returns:
      The result instance or null
    • execute

      int execute(String jpaql, Map<String,Object> parameters)
      Execute JPA-QL operation on data (Update, Delete).
      Parameters:
      jpaql - the JPA-QL query
      parameters - 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 to false.
      Parameters:
      useFlushMode - the new value to set
      Since:
      2.5
    • setSlowQueriesThreshold

      void setSlowQueriesThreshold(Duration threshold)
      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

      void save(Object object)
      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

      void update(Object object)
      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

      void saveOrUpdate(Object object)
      Either save(Object) or update(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

      void delete(Object object)
      Remove a persistent instance. This method is "inspired" of the Hibernate's Session#delete method.
      Parameters:
      object - the instance to be removed