To keep accidentally data coercion with JDBC happening with SQL templates type annotations might be useful using the format -- {name:type} and --{:type}.
Example:
SELECT * FROM STUFF
WHERE ID = 1 -- {id:long}
Obviously this is not compile time type safety but run time type checking. That is for example if you bind a int, Integer, or String or anything else that is not a long or Long an error will happen when the place holders parameters are merged (.mergedParameters()). The type annotations will need to be consistent. That is you cannot later set -- {id:String} with in the same SQL template.
To keep accidentally data coercion with JDBC happening with SQL templates type annotations might be useful using the format
-- {name:type}
and--{:type}
.Example:
Obviously this is not compile time type safety but run time type checking. That is for example if you bind a
int
,Integer
, orString
or anything else that is not along
orLong
an error will happen when the place holders parameters are merged (.mergedParameters()
). The type annotations will need to be consistent. That is you cannot later set-- {id:String}
with in the same SQL template.