public class JpqlBuilderImpl extends Object implements JpqlBuilder
Param and functions for setting parameters in a Query, also based
on Param. Supports all comparison expressions except between when
building jpql.| Modifier and Type | Field and Description |
|---|---|
static String |
TABLE_ALIAS
tabel alias used in building where and order by clause.
|
| Constructor and Description |
|---|
JpqlBuilderImpl() |
| Modifier and Type | Method and Description |
|---|---|
String |
orderClause(Map<String,CrudReadService.SORTORDER> sort)
builds an order by clause, uses
TABLE_ALIAS as alias for the
table |
protected void |
set(javax.persistence.Query q,
String key,
Object value)
When Query is a TypedQuery call
Query.setParameter(java.lang.String, java.lang.Object)
otherwise call Query.setParameter(int, java.lang.Object) with Short.valueOf(key). |
void |
setParam(javax.persistence.Query q,
Param param)
Fills parameters prepared in
setWhereParams(javax.persistence.Query, java.util.List), if the type of the field in the query is a Short or an Integer and the
paramValue is a String, it is converted accordingly. |
void |
setWhereParams(javax.persistence.Query q,
List<Param> params)
Calls
setParam(javax.persistence.Query, org.fryske_akademy.ejb.Param) for each filter. |
String |
whereClause(List<Param> params)
builds a where clause, calls
whereCondition(org.fryske_akademy.ejb.Param)
for every entry, uses TABLE_ALIAS as alias for the table |
String |
whereCondition(Param param)
builds a where condition, prepares ql parameters later filled in
setWhereParams(javax.persistence.Query, java.util.List). |
public static final String TABLE_ALIAS
public String orderClause(Map<String,CrudReadService.SORTORDER> sort)
TABLE_ALIAS as alias for the
tableorderClause in interface JpqlBuildersort - public String whereClause(List<Param> params)
whereCondition(org.fryske_akademy.ejb.Param)
for every entry, uses TABLE_ALIAS as alias for the tablewhereClause in interface JpqlBuilderparams - JpqlBuilder.whereCondition(org.fryske_akademy.ejb.Param),
JpqlBuilder.setWhereParams(javax.persistence.Query, java.util.List)public String whereCondition(Param param)
setWhereParams(javax.persistence.Query, java.util.List).
Collection as Param.getParamValue() with operator "member of"
supported!, in that case multiple member of conditions will be
constructed using a parameter key Param.getParamKey() with an
index number appended, these parameters and later filled by
setParam(javax.persistence.Query, org.fryske_akademy.ejb.Param).
Supports all comparison operators in Param.getOperator() except
between, for null and empty comparison Param.getNot()
and Param.getParamValue() are ignored.whereCondition in interface JpqlBuilderparam - JpqlBuilder.setWhereParams(javax.persistence.Query, java.util.List)public void setWhereParams(javax.persistence.Query q,
List<Param> params)
setParam(javax.persistence.Query, org.fryske_akademy.ejb.Param) for each filter.setWhereParams in interface JpqlBuilderq - params - protected void set(javax.persistence.Query q,
String key,
Object value)
Query.setParameter(java.lang.String, java.lang.Object)
otherwise call Query.setParameter(int, java.lang.Object) with Short.valueOf(key).q - key - value - public void setParam(javax.persistence.Query q,
Param param)
setWhereParams(javax.persistence.Query, java.util.List), if the type of the field in the query is a Short or an Integer and the
paramValue is a String, it is converted accordingly. For native queries Param.getParamKey() should
be a numeric positional parameter.
When the operator is
member of and the value is a Collection a value is set for each entry in
the collection, for this a parameter key Param.getParamKey()
with an index number appended is assumed, whereCondition(org.fryske_akademy.ejb.Param) prepares this. For the type check either
Parameter.getParameterType() is used, or, when null, Param.getParamType(). If the query does not contain the parameter and
Param.isSkipSetValue() is true, the parameter isn't set. Via
Param you have full control over the Object that is used as paramValue.setParam in interface JpqlBuilderq - param - Copyright © 2018 Fryske Akademy. All rights reserved.