Package de.calamanari.adl.sql
Interface QueryParameterCreator
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
DefaultQueryParameterCreator
A
QueryParameterCreator creates a QueryParameter from an argument value of an expression.- Author:
- Karl Eilebrecht
-
Method Summary
Modifier and TypeMethodDescriptioncreateParameter(de.calamanari.adl.cnv.tps.ArgMetaInfo argMetaInfo, String argValue, de.calamanari.adl.irl.MatchOperator matchOperator, AdlSqlType adlSqlType) Takes an argument from an expression withAdlTypeinformation as its input to create aQueryParameterto be applied to aPreparedStatementat a later time.createParameter(String id, de.calamanari.adl.cnv.tps.ArgMetaInfo argMetaInfo, String argValue, de.calamanari.adl.irl.MatchOperator matchOperator, AdlSqlType adlSqlType) Takes an argument from an expression withAdlTypeinformation as its input to create aQueryParameterto be applied to aPreparedStatementat a later time.booleanisTypeCombinationSupported(de.calamanari.adl.cnv.tps.AdlType sourceType, AdlSqlType targetType) This method tells whether an argument of the given sourceType can be mapped to the targetType to create a valid SQL-parameter.
It is meant for detecting configuration errors early.
-
Method Details
-
createParameter
QueryParameter createParameter(String id, de.calamanari.adl.cnv.tps.ArgMetaInfo argMetaInfo, String argValue, de.calamanari.adl.irl.MatchOperator matchOperator, AdlSqlType adlSqlType) Takes an argument from an expression withAdlTypeinformation as its input to create aQueryParameterto be applied to aPreparedStatementat a later time.- Parameters:
id- the temporary id of the new parameter, seeQueryParameter, NOT NULL (usecreateParameter(ArgMetaInfo, String, MatchOperator, AdlSqlType)instead)argMetaInfo- describes the source argument typeargValue- value to be passed as parameter of a querymatchOperator- context information: the operation the parameter is required foradlSqlType- requested type (target column)- Returns:
- parameter for PreparedStatement execution
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- in case of incompatibilities and errors
-
createParameter
QueryParameter createParameter(de.calamanari.adl.cnv.tps.ArgMetaInfo argMetaInfo, String argValue, de.calamanari.adl.irl.MatchOperator matchOperator, AdlSqlType adlSqlType) Takes an argument from an expression withAdlTypeinformation as its input to create aQueryParameterto be applied to aPreparedStatementat a later time.- Parameters:
argMetaInfo- describes the source argument typeargValue- value to be passed as parameter of a querymatchOperator- context information: the operation the parameter is required foradlSqlType- requested type (target column)- Returns:
- parameter for PreparedStatement execution
- Throws:
de.calamanari.adl.cnv.tps.AdlFormattingException- in case of incompatibilities and errors
-
isTypeCombinationSupported
boolean isTypeCombinationSupported(de.calamanari.adl.cnv.tps.AdlType sourceType, AdlSqlType targetType) This method tells whether an argument of the given sourceType can be mapped to the targetType to create a valid SQL-parameter.
It is meant for detecting configuration errors early.Important: This method only tells that a conversion from the source type to the target type might be possible. It can still happen that a particular value will be rejected at runtime.
Examples:
- A string to integer conversion is only possible if the input value is the textual representation of an integer. This method should return true
- It is principally impossible to turn a boolean into a date. This method should return false.
AdlSqlTypes shall be incompatible (return false) to anyAdlSqlType(even itself) to ensure SQL-types cannot be abused for the logical data model.- Parameters:
sourceType- argument type from the logical data modeltargetType- column type- Returns:
- true if the combination is supported by this creator, otherwise false
-