Enum Class QueryDistinctStrategy

java.lang.Object
java.lang.Enum<QueryDistinctStrategy>
ch.tocco.nice2.persist.core.impl.hibernate.query.QueryDistinctStrategy
All Implemented Interfaces:
Serializable, Comparable<QueryDistinctStrategy>, Constable

public enum QueryDistinctStrategy extends Enum<QueryDistinctStrategy>
Strategy regarding the `distinct` keyword to use for queries. Set the desired strategy by the application property `nice2.persist.queryDistinctStrategy` (e.g. `nice2.persist.queryDistinctStrategy=DISTINCT_IF_NECESSARY`).
  • Enum Constant Details

    • DISTINCT_ALWAYS

      public static final QueryDistinctStrategy DISTINCT_ALWAYS
      Legacy query mode where every query is executed with the `distinct` keyword to filter out possible duplicates. Leads to slow queries especially if tables are getting bigger.
    • PARALLEL_COMPARISON

      public static final QueryDistinctStrategy PARALLEL_COMPARISON
      Returns the result from the legacy query - so nothing changes for the user compared to the strategy DISTINCT_ALWAYS. However, additionally every query is executed in the new mode without `distinct` if possible, too. The results from the new query are compared with those from the legacy query and if there's a different number of results, an error is logged. Additionally, the query durations are recorded. Enable the debug level for the package `ch.tocco.nice2.persist.core.impl.hibernate.query` to log the query durations (along with the saved query time): `logging.level.ch.tocco.nice2.persist.core.impl.hibernate.query=DEBUG` So, this strategy should just be used during an early test phase to verify that the new queries work everywhere and to measure the potential performance improvements.
    • DISTINCT_IF_NECESSARY

      public static final QueryDistinctStrategy DISTINCT_IF_NECESSARY
      New query mode where the `distinct` keyword is only added if necessary. That is if there are outer joins for to-many relationships are in the query (which actually aren't that many). Executing the queries without the `distinct` keyword where possible leads to quite a big performance boost (e.g. some queries which take multiple seconds with the `distinct` keyword only take 1 ms without it).
  • Method Details

    • values

      public static QueryDistinctStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static QueryDistinctStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null