-->
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: Input host variable too large with criteria query??
PostPosted: Tue Jul 20, 2004 1:38 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 1:48 pm
Posts: 28
Hello,

I am seeking insight into an error I am getting using Hibernate. Any help will be greatly appreciated. I am using Hibernate 2.1.4 on Windows XP to query DB2 version 7.2 sitting on MVS (OS390). When I execute the following code:

Code:
SessionFactory factory = cfg.buildSessionFactory();
Session s = factory.openSession();
Transaction tx = null;
List list = null;
try {
                tx = s.beginTransaction();
   Criteria crit = null;
                s.createCriteria(CrsOffer.class)              .add(Expression.eq("comp_id.year", yearIn))
     .add(Expression.eq("comp_id.term", termIn))
     .add(Expression.eq("comp_id.camp", campIn))
     .add(Expression.eq("comp_id.sect", sectIn));

   list = crit.list();
                CrsOffer crsOffer = (CrsOffer)list.get(0);
                tx.commit();
                Set set = crsOffer.getCrsReqCodes();
} // end try


I get the SQL ERROR 302 which my DBA says is probably caused by the host variable being used is too large. I used middlegen to create my mappings and the hiberbate tools to generate the java classes. Below is the stack trace and following that are the rerlevant mapping files.


13:23:07,676 DEBUG SQL:237 - select this.REQ_CODE as REQ_CODE0_, this.YEAR as YEAR0_, this.TERM as TERM0_, this.CAMP as CAMP0_, this.CRS_NAM as CRS_NAM0_, this.CRS_NBR as CRS_NBR0_, this.SECT as SECT0_, this.UPDT_USRID as UPDT_USRID0_, this.UPDT_PGM as UPDT_PGM0_, this.UPDT_TSTMP as UPDT_TSTMP0_ from ECU.CRS_REQ_CODE this where (this.YEAR=? and this.TERM=? and this.CAMP=? and this.CRS_NAM=? and this.CRS_NBR=? and this.SECT=?)
Hibernate: select this.REQ_CODE as REQ_CODE0_, this.YEAR as YEAR0_, this.TERM as TERM0_, this.CAMP as CAMP0_, this.CRS_NAM as CRS_NAM0_, this.CRS_NBR as CRS_NBR0_, this.SECT as SECT0_, this.UPDT_USRID as UPDT_USRID0_, this.UPDT_PGM as UPDT_PGM0_, this.UPDT_TSTMP as UPDT_TSTMP0_ from ECU.CRS_REQ_CODE this where (this.YEAR=? and this.TERM=? and this.CAMP=? and this.CRS_NAM=? and this.CRS_NBR=? and this.SECT=?)
13:23:07,736 WARN JDBCExceptionReporter:38 - SQL Error: -302, SQLState: 22001
13:23:07,736 ERROR JDBCExceptionReporter:46 - DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 006;
13:23:07,736 WARN JDBCExceptionReporter:38 - SQL Error: -302, SQLState: 22001
13:23:07,746 ERROR JDBCExceptionReporter:46 - DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 006;
13:23:07,746 ERROR JDBCExceptionReporter:38 - SQLException occurred
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 006;
at com.ibm.db2.jcc.c.cl.e(cl.java:1213)
at com.ibm.db2.jcc.c.cl.a(cl.java:946)
at com.ibm.db2.jcc.a.bd.n(bd.java:516)
at com.ibm.db2.jcc.a.bd.i(bd.java:224)
at com.ibm.db2.jcc.a.bd.c(bd.java:56)
at com.ibm.db2.jcc.a.r.c(r.java:53)
at com.ibm.db2.jcc.a.bp.h(bp.java:118)
at com.ibm.db2.jcc.c.cl.i(cl.java:942)
at com.ibm.db2.jcc.c.cm.c(cm.java:1653)
at com.ibm.db2.jcc.c.cm.B(cm.java:296)
at com.ibm.db2.jcc.c.cm.executeQuery(cm.java:279)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3609)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at net.sf.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:383)
at Lazy.go(Lazy.java:57)
at Lazy.main(Lazy.java:14)
Inside addCourse(): net.sf.hibernate.JDBCException: SQLException occurred


CrsOffer.hbm.xml


<class
name="CrsOffer"
table="CRS_OFFER"
>

<composite-id name="comp_id" class="CrsOfferPK">
<key-property
name="year"
column="YEAR"
type="java.lang.String"
length="4"
/>
<key-property
name="term"
column="TERM"
type="java.lang.String"
length="1"
/>
<key-property
name="camp"
column="CAMP"
type="java.lang.String"
length="3"
/>
<key-property
name="sect"
column="SECT"
type="java.lang.String"
length="3"
/>
<!-- bi-directional many-to-one association to CatCr -->
<key-many-to-one
name="catCr"
class="CatCr"
>
<column name="CRS_NAM" />
<column name="CRS_NBR" />
</key-many-to-one>


</composite-id>

<property
name="supplTitle"
type="java.lang.String"
column="SUPPL_TITLE"
not-null="true"
length="21"
/>

<property
name="crteTstmp"
type="java.sql.Timestamp"
column="CRTE_TSTMP"
length="26"
/>
<property
name="crtePgm"
type="java.lang.String"
column="CRTE_PGM"
length="8"
/>
<property
name="crteUsrid"
type="java.lang.String"
column="CRTE_USRID"
length="8"
/>

<!-- bi-directional one-to-many association to CrsReqCode -->
<set
name="crsReqCodes"
lazy="true"
inverse="true"
>
<key>
<column name="YEAR" />
<column name="TERM" />
<column name="CAMP" />
<column name="CRS_NAM" />
<column name="CRS_NBR" />
<column name="SECT" />
</key>
<one-to-many
class="CrsReqCode"
/>
</set>


</class>
</hibernate-mapping>


CrsReqCode.hbm.xml


<class
name="CrsReqCode"
table="CRS_REQ_CODE"
>

<composite-id name="comp_id" class="CrsReqCodePK">
<!-- bi-directional many-to-one association to SchedReqCode -->
<key-many-to-one
name="schedReqCode"
class="SchedReqCode"
>
<column name="REQ_CODE" />
</key-many-to-one>
<!-- bi-directional many-to-one association to CrsOffer -->
<key-many-to-one
name="crsOffer"
class="CrsOffer"
>
<column name="YEAR" />
<column name="TERM" />
<column name="CAMP" />
<column name="CRS_NAM" />
<column name="CRS_NBR" />
<column name="SECT" />
</key-many-to-one>
</composite-id>

<property
name="updtUsrid"
type="java.lang.String"
column="UPDT_USRID"
not-null="true"
length="8"
/>
<property
name="updtPgm"
type="java.lang.String"
column="UPDT_PGM"
not-null="true"
length="8"
/>
<property
name="updtTstmp"
type="java.sql.Timestamp"
column="UPDT_TSTMP"
not-null="true"
length="26"
/>

<!-- associations -->

</class>
</hibernate-mapping>
[/i]


SchedReqCode.hbm.xml


<class
name="SchedReqCode"
table="SCHED_REQ_CODE"
>

<id
name="reqCode"
type="java.lang.String"
column="REQ_CODE"
>
<generator class="assigned" />
</id>

<property
name="updtUsrid"
type="java.lang.String"
column="UPDT_USRID"
not-null="true"
length="8"
/>
<property
name="updtPgm"
type="java.lang.String"
column="UPDT_PGM"
not-null="true"
length="8"
/>
<property
name="updtTstmp"
type="java.sql.Timestamp"
column="UPDT_TSTMP"
not-null="true"
length="26"
/>
<property
name="reqShortDesc"
type="java.lang.String"
column="REQ_SHORT_DESC"
not-null="true"
length="15"
/>
<property
name="fullDesc"
type="java.lang.String"
column="FULL_DESC"
not-null="true"
length="30"
/>

<!-- associations -->
<!-- bi-directional one-to-many association to CrsReqCode -->
<set
name="crsReqCodes"
lazy="true"
inverse="true"
>
<key>
<column name="REQ_CODE" />
</key>
<one-to-many
class="CrsReqCode"
/>
</set>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: still the same error with different tables
PostPosted: Tue Jul 20, 2004 8:50 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 1:48 pm
Posts: 28
I have tried a new scenerio using different tables which have the same characteristics as the ones mentioned above and I get the same result:

Code:
18:56:59,751 DEBUG SQL:237 - select asgminors0_.MINOR_CODE as MINOR_CODE__, asgminors0_.SSN as SSN__, asgminors0_.TERM as TERM__, asgminors0_.YEAR as YEAR__, asgminors0_.MINOR_CODE as MINOR_CODE0_, asgminors0_.SSN as SSN0_, asgminors0_.TERM as TERM0_, asgminors0_.YEAR as YEAR0_, asgminors0_.UPDT_USRID as UPDT_USRID0_, asgminors0_.UPDT_PGM as UPDT_PGM0_, asgminors0_.UPDT_TSTMP as UPDT_TSTMP0_, asgminors0_.MINOR_CONCN as MINOR_CO8_0_, asgminors0_.MINOR_OPT as MINOR_OPT0_ from ECU.ASG_MINOR asgminors0_ where asgminors0_.SSN=? and asgminors0_.TERM=? and asgminors0_.YEAR=?
18:56:59,941  WARN JDBCExceptionReporter:38 - SQL Error: -302, SQLState: 22001
18:56:59,941 ERROR JDBCExceptionReporter:46 - DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 002;
18:56:59,971  WARN JDBCExceptionReporter:38 - SQL Error: -302, SQLState: 22001
18:56:59,971 ERROR JDBCExceptionReporter:46 - DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 002;
18:56:59,991 ERROR JDBCExceptionReporter:38 - could not initialize collection: [TermRec.asgMinors#TermRecPK@147358f[term=1,year=2004,stu=Stu@199939[ssn=000000000]]]
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 002;
   at com.ibm.db2.jcc.c.cl.e(cl.java:1213)
   at com.ibm.db2.jcc.c.cl.a(cl.java:946)
   at com.ibm.db2.jcc.a.bd.n(bd.java:516)
   at com.ibm.db2.jcc.a.bd.i(bd.java:224)
   at com.ibm.db2.jcc.a.bd.c(bd.java:56)
   at com.ibm.db2.jcc.a.r.c(r.java:53)
   at com.ibm.db2.jcc.a.bp.h(bp.java:118)
   at com.ibm.db2.jcc.c.cl.i(cl.java:942)
   at com.ibm.db2.jcc.c.cm.c(cm.java:1653)
   at com.ibm.db2.jcc.c.cm.B(cm.java:296)
   at com.ibm.db2.jcc.c.cm.executeQuery(cm.java:279)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
   at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
   at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
   at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3264)
   at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
   at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
   at net.sf.hibernate.collection.Set.size(Set.java:106)
   at Registration3.<init>(Registration3.java:61)
   at RegClient.main(RegClient.java:7)
18:56:59,991 ERROR PersistentCollection:198 - Failed to lazily initialize a collection
net.sf.hibernate.JDBCException: could not initialize collection: [TermRec.asgMinors#TermRecPK@147358f[term=1,year=2004,stu=Stu@199939[ssn=000000000]]]
   at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:287)
   at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3264)
   at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:195)
   at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
   at net.sf.hibernate.collection.Set.size(Set.java:106)
   at Registration3.<init>(Registration3.java:61)
   at RegClient.main(RegClient.java:7)
Caused by: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: 002;
   at com.ibm.db2.jcc.c.cl.e(cl.java:1213)
   at com.ibm.db2.jcc.c.cl.a(cl.java:946)
   at com.ibm.db2.jcc.a.bd.n(bd.java:516)
   at com.ibm.db2.jcc.a.bd.i(bd.java:224)
   at com.ibm.db2.jcc.a.bd.c(bd.java:56)
   at com.ibm.db2.jcc.a.r.c(r.java:53)
   at com.ibm.db2.jcc.a.bp.h(bp.java:118)
   at com.ibm.db2.jcc.c.cl.i(cl.java:942)
   at com.ibm.db2.jcc.c.cm.c(cm.java:1653)
   at com.ibm.db2.jcc.c.cm.B(cm.java:296)
   at com.ibm.db2.jcc.c.cm.executeQuery(cm.java:279)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
   at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
   at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
   at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
   ... 6 more
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.