I'm trying to use Hibernate with HyperJaxb2 on a DB2/400 database. I have a simple junit test case that marshals an XML file into an object, stores it in hibernate, then re-loads it, unmarshals to XML & prints the XML. This works fine using the hypersonic db, but if I switch to the DB2/400, it fails in hibernate when trying to load the object. I know the store worked, because i can see the row in the table using other tools. From the hibernate debug trace, it appears that the PrepareStatement fails:
GOOD trace (hypersonic):
Hibernate: /* load com.triversity.te.integration.impl.TsD1Impl */ select tsd1impl0_.Hjid as Hjid0_, tsd1impl0_.Hjversion as Hjversion0_0_, tsd1impl0_.Tstring2 as Tstring4_0_0_, tsd1impl0_.Tstring1 as Tstring5_0_0_ from TsD1Type tsd1impl0_ where tsd1impl0_.Hjid=? and tsd1impl0_.Hjtype='com.triversity.te.integration.TsD1'
DEBUG [org.hibernate.jdbc.AbstractBatcher] - <preparing statement>
DEBUG [org.hibernate.type.LongType] - <binding '1' to parameter: 1>
DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to open ResultSet (open ResultSets: 0, globally: 0)>
DEBUG [org.hibernate.loader.Loader] - <processing result set>
FAILING trace (DB2/400):
{same as good trace...}
Hibernate: /* load com.triversity.te.integration.impl.TsD1Impl */ select tsd1impl0_.Hjid as Hjid0_, tsd1impl0_.Hjversion as Hjversion0_0_, tsd1impl0_.Tstring2 as Tstring4_0_0_, tsd1impl0_.Tstring1 as Tstring5_0_0_ from tedev.TsD1Type tsd1impl0_ where tsd1impl0_.Hjid=? and tsd1impl0_.Hjtype='com.triversity.te.integration.TsD1'
DEBUG [org.hibernate.jdbc.AbstractBatcher] - <preparing statement>
DEBUG [org.hibernate.type.LongType] - <binding '1' to parameter: 1>
{diverges from good trace here...}
DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to close PreparedStatement (open PreparedStatements: 1, globally: 1)>
DEBUG [org.hibernate.jdbc.AbstractBatcher] - <closing statement>
INFO [org.hibernate.connection.DriverManagerConnectionProvider] - <cleaning up connection pool: jdbc:as400://192.100.100.1/TEDEV>
DEBUG [org.hibernate.util.JDBCExceptionReporter] - <could not load an entity: [com.triversity.te.integration.impl.TsD1Impl#1] [/* load com.triversity.te.integration.impl.TsD1Impl */ select tsd1impl0_.Hjid as Hjid0_, tsd1impl0_.Hjversion as Hjversion0_0_, tsd1impl0_.Tstring2 as Tstring4_0_0_, tsd1impl0_.Tstring1 as Tstring5_0_0_ from tedev.TsD1Type tsd1impl0_ where tsd1impl0_.Hjid=? and tsd1impl0_.Hjtype='com.triversity.te.integration.TsD1']>
java.sql.SQLException: [SQL0518] Prepared statement STMT0001 not found.
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:364)
at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:616)
at com.ibm.as400.access.AS400JDBCPreparedStatement.executeQuery(AS400JDBCPreparedStatement.java:871)
...
The traces diverge after the <binding '1' to parameter 1> output. The failing case indicates the PreparedStatement is being closed... then we get the SQLException apparently because there's no prepared statement.
The hbm.xml files are identical in the two cases -- they're generated by HyperJaxb from my XSD. The only difference in the SQL statement being prepared (as seen in trace) is the AS400 code has the schema name prepended to the table name: "from tedev.TsD1Type" (as expected).
Any ideas?
-dwight
Hibernate version: 3.0.5
Name and version of the database you are using: DB2/400, iSeries V5R3; AS/400 toolbox v5.1.0 for jdbc access.
Code between sessionFactory.openSession() and session.close():
final Object loadedObject = loadSession.load(object.getClass(), id);
Mapping documents:
Code:
TsD1.hbm.xml:
<!DOCTYPE hibernate-mapping ...3.0.dtd">
<hibernate-mapping auto-import="false" default-cascade="all-delete-orphan" default-lazy="false">
<subclass extends="com.triversity.te.integration.TsD1Type" name="com.triversity.te.integration.TsD1">
<subclass discriminator-value="com.triversity.te.integration.TsD1" name="com.triversity.te.integration.impl.TsD1Impl"/>
</subclass>
</hibernate-mapping>
TsD1Type.hbm.xml:
<!DOCTYPE hibernate-mapping ...3.0.dtd">
<hibernate-mapping auto-import="false" default-cascade="all-delete-orphan" default-lazy="false">
<class name="com.triversity.te.integration.TsD1Type" table="TsD1Type">
<id name="Hjid" type="org.hibernate.type.LongType">
<generator class="native"/>
</id>
<discriminator type="org.hibernate.type.StringType">
<column name="Hjtype"/>
</discriminator>
<version name="Hjversion" type="org.hibernate.type.LongType"/>
<property name="Tstring2">
<column name="Tstring2"/>
<type name="org.hibernate.type.StringType"/>
</property>
<property name="Tstring1">
<column name="Tstring1"/>
<type name="org.hibernate.type.StringType"/>
</property>
<subclass discriminator-value="com.triversity.te.integration.TsD1Type" name="com.triversity.te.integration.impl.TsD1TypeImpl"/>
</class>
</hibernate-mapping>