Class HqlUtils

java.lang.Object
uk.ac.ebi.utils.sql.HqlUtils

public class HqlUtils extends Object
Utilities for SQL definition and manipulation.
date
Jun 17, 2013
Author:
Marco Brandizi
  • Constructor Details

    • HqlUtils

      public HqlUtils()
  • Method Details

    • parameterizedWithNullHql

      public static String parameterizedWithNullHql(String fieldName, String paramName)
      Builds a string like ":paramName IS NULL AND fieldName IS NULL OR fieldName = :paramName". This is useful for building parameterised queries where you want to match a particular value, including the null value.
    • parameterizedRangeClause

      public static <T> String parameterizedRangeClause(String fieldName, String paramLo, String paramHi, T lo, T hi)
      Builds a query clause that restricts fieldName in the specified range. Uses '<=' , '<=' or BETWEEN, depending on the lo, hi value. The returned HQL string contains only paramLo, paramHi, not the lo, hi values themselves. You should use parameterizedRangeBinding(Query, String, String, Object, Object) with a Query built this way.
    • parameterizedRangeBinding

      public static <T> javax.persistence.Query parameterizedRangeBinding(javax.persistence.Query q, String paramLo, String paramHi, T lo, T hi)
      Binds a clause built with parameterizedRangeClause(String, String, String, Object, Object) with the values lo, hi.