@ApplicationScoped @Named public class JpqlBuilderImpl extends Object implements JpqlBuilder
| Modifier and Type | Field and Description |
|---|---|
static String |
ENTITY_PREFIX |
| Constructor and Description |
|---|
JpqlBuilderImpl() |
| Modifier and Type | Method and Description |
|---|---|
String |
orderClause(Map<String,CrudReadService.SORTORDER> sort)
builds an order by clause, uses
ENTITY_PREFIX. |
protected void |
set(javax.persistence.Query q,
String key,
Object value)
When the Query has the parameter "key" call
Query.setParameter(java.lang.String, java.lang.Object)
otherwise call Query.setParameter(int, java.lang.Object) with
Short.valueOf(key), because then a positional parameter in a native query
is assumed. |
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(Query, Param) for each filter. |
String |
whereClause(List<Param> params)
builds a where clause, calls
whereCondition(Param)
for every entry. |
String |
whereCondition(Param param)
builds a where condition, prepares query parameters later filled in
setWhereParams(javax.persistence.Query, java.util.List). |
public static final String ENTITY_PREFIX
public String orderClause(Map<String,CrudReadService.SORTORDER> sort)
ENTITY_PREFIX.orderClause in interface JpqlBuildersort - public String whereClause(List<Param> params)
whereCondition(Param)
for every entry.whereClause in interface JpqlBuilderparams - JpqlBuilder.whereCondition(Param),
JpqlBuilder.setWhereParams(javax.persistence.Query, java.util.List)public String whereCondition(Param param)
setWhereParams(javax.persistence.Query, java.util.List). "member of" support for singular param value and for a collection
as param value, when param value is a collection multiple "member of" conditions are generated.
"between" is not supported.whereCondition in interface JpqlBuilderparam - JpqlBuilder.setWhereParams(javax.persistence.Query, java.util.List)public void setWhereParams(javax.persistence.Query q,
List<Param> params)
setParam(Query, 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), because then a positional parameter in a native query
is assumed.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(Param) prepares this. For the type check either
Parameter.getParameterType() is used, or, when null, Param.getParamType(). Via
Param you have full control over the Object that is used as paramValue.setParam in interface JpqlBuilderq - param - Copyright © 2018–2020 Fryske Akademy. All rights reserved.