Hi,
I'm running tests with hibernate and HSQLDB and found that hibernate improperly generates a tuple syntax even if the HSQLDialect does not support rowvalueconstructor. This same tuple syntax works fine on Oracle10g. Why Hibernate would generate such SQL even for dialects that don't support row value constructor ?
See org.hibernate.dialect.HSQLDialect.supportsRowValueConstructorSyntax()
org.hibernate.dialect.HSQLDialect.supportsRowValueConstructorSyntaxInInList()
Hibernate version:
3.2.6
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.archinsurance.rdm.entity.reference.impl">
<class name="SpecificationRelationInstanceImpl" table="SPECIFICATION_RELATIONSHIP">
<composite-id name="id" class="SpecRelationshipPK">
<key-property name="specificationId1" column="SPECIFICATION1_ID" type="long" />
<key-property name="specificationId2" column="SPECIFICATION2_ID" type="long" />
<key-property name="typeCd" column="TYPE_CD" type="string" />
</composite-id>
<property name="rowCreateTimestamp" column="ROW_CREATE_TS" type="timestamp" update="false" />
<property name="rowUpdateTimestamp" column="ROW_UPDATE_TS" type="timestamp" />
<property name="rowEndTimestamp" column="ROW_END_TS" type="timestamp" update="false"/>
<component name="validityPeriod" class="com.archinsurance.rdm.entity.reference.ValidityPeriod">
<property name="validFromDate" column="VALID_FROM_DT" type="date" />
<property name="validToDate" column="VALID_TO_DT" type="date" />
</component>
<many-to-one name="referenceDomainRelationInstance" class="ReferenceDomainRelationInstanceImpl"
column="DOMAIN_OBJECT_INSTANCE_ID" />
<many-to-one name="specification1" class="SpecificationImpl" column="SPECIFICATION1_ID" update="false" insert="false" lazy="false" />
<many-to-one name="specification2" class="SpecificationImpl" column="SPECIFICATION2_ID" update="false" insert="false" lazy="false" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
entityManager.createQuery("from SpecificationRelationInstanceImpl e where e.id in (:list)").setParameter("list", listParam).getResultList();
Full stack trace of any exception that occurs:Code:
17:15:37,013 DEBUG [JDBCExceptionReporter] could not execute query [select specificat0_.SPECIFICATION1_ID as SPECIFIC1_95_, specificat0_.SPECIFICATION2_ID as SPECIFIC2_95_, specificat0_.TYPE_CD as TYPE3_95_, specificat0_.ROW_CREATE_TS as ROW4_95_, specificat0_.ROW_UPDATE_TS as ROW5_95_, specificat0_.ROW_END_TS as ROW6_95_, specificat0_.VALID_FROM_DT as VALID7_95_, specificat0_.VALID_TO_DT as VALID8_95_, specificat0_.DOMAIN_OBJECT_INSTANCE_ID as DOMAIN9_95_ from SPECIFICATION_RELATIONSHIP specificat0_ where (specificat0_.SPECIFICATION1_ID, specificat0_.SPECIFICATION2_ID, specificat0_.TYPE_CD) in ((?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?))]
java.sql.SQLException: Unexpected token: , in statement [select specificat0_.SPECIFICATION1_ID as SPECIFIC1_95_, specificat0_.SPECIFICATION2_ID as SPECIFIC2_95_, specificat0_.TYPE_CD as TYPE3_95_, specificat0_.ROW_CREATE_TS as ROW4_95_, specificat0_.ROW_UPDATE_TS as ROW5_95_, specificat0_.ROW_END_TS as ROW6_95_, specificat0_.VALID_FROM_DT as VALID7_95_, specificat0_.VALID_TO_DT as VALID8_95_, specificat0_.DOMAIN_OBJECT_INSTANCE_ID as DOMAIN9_95_ from SPECIFICATION_RELATIONSHIP specificat0_ where (specificat0_.SPECIFICATION1_ID, specificat0_.SPECIFICATION2_ID, specificat0_.TYPE_CD) in ((?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?) , (?, ?, ?))]
at org.hsqldb.jdbc.Util.throwError(Util.java:56)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(jdbcPreparedStatement.java:1820)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(jdbcConnection.java:563)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
at com.archinsurance.deployer.service.impl.DeploymentTargetImpl.getTargetEntities(DeploymentTargetImpl.java:184)
at com.archinsurance.deployer.service.impl.DeploymentTargetImpl.performDeployForSelectableEntity(DeploymentTargetImpl.java:148)
at com.archinsurance.deployer.service.impl.DeploymentTargetImpl.performDeploy(DeploymentTargetImpl.java:116)
at com.archinsurance.deployer.service.impl.DeploymentTargetImplTest.testPerformDeployVanilla(DeploymentTargetImplTest.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.MethodHelper$1.runTestMethod(MethodHelper.java:698)
at org.springframework.test.context.testng.AbstractTestNGSpringContextTests.run(AbstractTestNGSpringContextTests.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.testng.internal.MethodHelper.invokeHookable(MethodHelper.java:706)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:468)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
at org.testng.TestRunner.runWorkers(TestRunner.java:712)
at org.testng.TestRunner.privateRun(TestRunner.java:582)
at org.testng.TestRunner.run(TestRunner.java:477)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:198)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
at org.testng.TestNG.run(TestNG.java:708)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
17:15:37,013 WARN [JDBCExceptionReporter] SQL Error: -11, SQLState: 37000
Name and version of the database you are using:
HSQLDB 1.8.0.7
The generated SQL (show_sql=true):
select
specificat0_.SPECIFICATION1_ID as SPECIFIC1_95_,
specificat0_.SPECIFICATION2_ID as SPECIFIC2_95_,
specificat0_.TYPE_CD as TYPE3_95_,
specificat0_.ROW_CREATE_TS as ROW4_95_,
specificat0_.ROW_UPDATE_TS as ROW5_95_,
specificat0_.ROW_END_TS as ROW6_95_,
specificat0_.VALID_FROM_DT as VALID7_95_,
specificat0_.VALID_TO_DT as VALID8_95_,
specificat0_.DOMAIN_OBJECT_INSTANCE_ID as DOMAIN9_95_
from
SPECIFICATION_RELATIONSHIP specificat0_
where
(
specificat0_.SPECIFICATION1_ID, specificat0_.SPECIFICATION2_ID, specificat0_.TYPE_CD
) in (
(
?, ?, ?
) , (
?, ?, ?
) , (
?, ?, ?
) , (
?, ?, ?
) , (
?, ?, ?
) , (
?, ?, ?
) , (
?, ?, ?
) , (
?, ?, ?
)
)