Package uk.ac.ebi.utils.sql
Class HqlUtils
java.lang.Object
uk.ac.ebi.utils.sql.HqlUtils
Utilities for SQL definition and manipulation.
- date
- Jun 17, 2013
- Author:
- Marco Brandizi
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> javax.persistence.Query
parameterizedRangeBinding
(javax.persistence.Query q, String paramLo, String paramHi, T lo, T hi) Binds a clause built withparameterizedRangeClause(String, String, String, Object, Object)
with the values lo, hi.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.static String
parameterizedWithNullHql
(String fieldName, String paramName) Builds a string like ":paramName IS NULL AND fieldName IS NULL OR fieldName = :paramName".
-
Constructor Details
-
HqlUtils
public HqlUtils()
-
-
Method Details
-
parameterizedWithNullHql
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'<='
,'<='
orBETWEEN
, depending on the lo, hi value. The returned HQL string contains only paramLo, paramHi, not the lo, hi values themselves. You should useparameterizedRangeBinding(Query, String, String, Object, Object)
with aQuery
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 withparameterizedRangeClause(String, String, String, Object, Object)
with the values lo, hi.
-