Package org.fryske_akademy.jpa
Class JpqlBuilderImpl
java.lang.Object
org.fryske_akademy.jpa.JpqlBuilderImpl
- All Implemented Interfaces:
JpqlBuilder
Stateless, threadsafe builder containing functions for building jpql}.
Supports all comparison when building jpql.
- Author:
- eduard
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilds an order by clause, usesENTITY_PREFIX.protected voidWhen the Query has the parameter "key" callQuery.setParameter(java.lang.String, java.lang.Object)otherwise callQuery.setParameter(int, java.lang.Object)with Short.valueOf(key), because then a positional parameter in a native query is assumed.voidFills parameters prepared insetWhereParams(jakarta.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.voidsetWhereParams(jakarta.persistence.Query q, List<Param> params) CallssetParam(Query, Param)for each filter.whereClause(List<Param> params) builds a where clause, callswhereCondition(Param)for every entry.whereCondition(Param param) builds a where condition, prepares query parameters later filled insetWhereParams(jakarta.persistence.Query, java.util.List).
-
Field Details
-
ENTITY_PREFIX
- See Also:
-
-
Constructor Details
-
JpqlBuilderImpl
public JpqlBuilderImpl()
-
-
Method Details
-
orderClause
builds an order by clause, usesENTITY_PREFIX.- Specified by:
orderClausein interfaceJpqlBuilder- Parameters:
sort-- Returns:
-
whereClause
builds a where clause, callswhereCondition(Param)for every entry.- Specified by:
whereClausein interfaceJpqlBuilder- Parameters:
params-- Returns:
- See Also:
-
whereCondition
builds a where condition, prepares query parameters later filled insetWhereParams(jakarta.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.- Specified by:
whereConditionin interfaceJpqlBuilder- Parameters:
param-- Returns:
- See Also:
-
setWhereParams
CallssetParam(Query, Param)for each filter.- Specified by:
setWhereParamsin interfaceJpqlBuilder- Parameters:
q-params-
-
set
When the Query has the parameter "key" callQuery.setParameter(java.lang.String, java.lang.Object)otherwise callQuery.setParameter(int, java.lang.Object)with Short.valueOf(key), because then a positional parameter in a native query is assumed. When the value is anOPERATORuseOPERATOR.getUserInput()as value.- Parameters:
q-key-value-
-
setParam
Fills parameters prepared insetWhereParams(jakarta.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 queriesParam.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 keyParam.getParamKey()with an index number appended is assumed,whereCondition(Param)prepares this. For the type check eitherParameter.getParameterType()is used, or, when null,Param.getParamType(). Via Param you have full control over the Object that is used as paramValue.- Specified by:
setParamin interfaceJpqlBuilder- Parameters:
q-param-
-