Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0
-
None
Description
When binding collections as EJBQL variable, Cayenne erroneously binds each collection value as VARBINARY at the JDBC level. This works ok on some DB's (hiding the problem) but breaks on some others. E.g. on SQLServer:
List<Integer> id = ...
String ejbql = "delete from MeaningfulPKTest1 m WHERE m.pkAttribute in (:id)";
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("id", id);
Results in the following error:
INFO: *** error.
com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from INTEGER to VARBINARY is unsupported.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)
at com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:879)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:913)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:884)
at org.apache.cayenne.access.types.AbstractType.setJdbcObject(AbstractType.java:79)
at org.apache.cayenne.dba.JdbcAdapter.bindParameter(JdbcAdapter.java:497)
at org.apache.cayenne.dba.sybase.SybaseAdapter.bindParameter(SybaseAdapter.java:99)
at org.apache.cayenne.access.jdbc.SQLTemplateAction.bind(SQLTemplateAction.java:325)
at org.apache.cayenne.access.jdbc.SQLTemplateAction.execute(SQLTemplateAction.java:150)
at org.apache.cayenne.access.jdbc.SQLTemplateAction.performAction(SQLTemplateAction.java:127)
at org.apache.cayenne.access.jdbc.EJBQLAction.performAction(EJBQLAction.java:101)
at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:58)
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:237)
at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:424)
at org.apache.cayenne.access.DataDomainQueryAction.access$0(DataDomainQueryAction.java:403)
at org.apache.cayenne.access.DataDomainQueryAction$2.transform(DataDomainQueryAction.java:397)
at org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:847)
at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:394)
at org.apache.cayenne.access.UnitTestDomainQueryAction.runQueryInTransaction(UnitTestDomainQueryAction.java:55)
at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:120)
at org.apache.cayenne.access.UnitTestDomainQueryAction.execute(UnitTestDomainQueryAction.java:49)
at org.apache.cayenne.access.UnitTestDomain.onQuery(UnitTestDomain.java:63)
at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:317)
at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:96)
at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1326)
at org.apache.cayenne.access.DataContext.performGenericQuery(DataContext.java:1285)
at org.apache.cayenne.access.DataContextEJBQLDeleteTest.testDeleteIdVar(DataContextEJBQLDeleteTest.java:98)
The problem is SQLTemplate #bind directive incomplete collection handling.