I'm trying to use a SQLTemplate with an 'IN' expression and binding a
Collection, as described in the docs for "Scripting SQLTemplate". I
keep getting an error like this:
org.apache.velocity.exception.ParseErrorException: Can't determine JDBC
type of binding ([AR, HI], null) at line 1, column 93
at
org.objectstyle.cayenne.access.jdbc.BindDirective.render(BindDirective.java:134)
at
org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:153)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:271)
at
org.objectstyle.cayenne.access.jdbc.SQLTemplateProcessor.buildStatement(SQLTemplateProcessor.java:232)
at
org.objectstyle.cayenne.access.jdbc.SQLTemplateProcessor.processTemplate(SQLTemplateProcessor.java:192)
at
org.objectstyle.cayenne.access.jdbc.SQLTemplateAction.performAction(SQLTemplateAction.java:136)
The code:
String sql = "select t.* from tablename t where t.state IN (#bind($states))";
Map parms = new HashMap();
parms.put("states", Arrays.asList(new String[] { "AR", "HI"}));
SQLTemplate query = new SQLTemplate(MyObject.class, sql);
query.setFetchLimit(maxListSize);
query.setParameters(parms);
List objects = dataContext.performQuery(query);
Other bindings, not involving Collections, are working fine.
I took a glance at the source and it appears that the wrong method is
being called. The render() method BindDirective.java:134 doesn't check
for the value being a Collection, but the other render() method does.
Maybe I need to specify something else?
This archive was generated by hypermail 2.0.0 : Mon Oct 23 2006 - 13:15:40 EDT