jirm icon indicating copy to clipboard operation
jirm copied to clipboard

Type annotations in SQL template placeholders

Open agentgt opened this issue 11 years ago • 0 comments

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.

agentgt avatar Mar 13 '13 14:03 agentgt