-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Load on DB2/400 gets SQL0518 Prepared statement not found
PostPosted: Wed Dec 14, 2005 3:02 pm 
Beginner
Beginner

Joined: Wed Nov 30, 2005 2:41 pm
Posts: 29
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>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 9:40 pm 
Beginner
Beginner

Joined: Wed Nov 30, 2005 2:41 pm
Posts: 29
I installed hibernate 3.1 & this still happens. Test works (save + load) with HSQLDB, but using the AS400, I can save, but not load. The load always gets "[SQL0518] Prepared statement STMT0001 not found."

This is our first attempt using Hibernate on the AS400; it hasn't worked yet -- so it's probably something simple, but the symptom is sure obscure. The generate SQL (in trace in previous post) seems correct; i can copy it to my db utility, change the "?" to 1, and it fetches the desired row.

I stepped thru the code, and in Loader.doQuery(), the code does:
final PreparedStatement st = prepareQueryStatement( queryParameters, false, session );

This returns a non-null st, but when getResultSet calls AS400JDBCPreparedStatement.executeQuery, it throws the SQL0518 exception.

hbm.xml & application code as shown in prior post.
I'm using the built-in hibernate connection pool.

hibernate.properties:
Code:
hibernate.default_schema tedev
hibernate.dialect org.hibernate.dialect.DB2400Dialect
hibernate.connection.username xxx
hibernate.connection.password xxx
hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
hibernate.connection.url jdbc:as400://192.100.100.123/TEDEV
...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.