-->
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.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.exception.SQLGrammarException: could not load
PostPosted: Tue May 17, 2005 7:26 am 
Beginner
Beginner

Joined: Thu May 20, 2004 3:40 pm
Posts: 33
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hello!!

Just trying to figure out what I am missing when I get the following error:

org.hibernate.exception.SQLGrammarException: could not load an entity batch: [com.gs.fw.cmpl.de.data.Trade#<component[tradeDate,tranValue,tranQty]{
nValue=11377.46, tranQty=11377.46, tradeDate=03 November 2004}, component[tradeDate,tranValue,tranQty]{tranValue=709500.0, tranQty=15000.0, tradeDa????


Hibernate version:
3.0.3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="amlusprod" default-lazy="false">

<class name="com.gs.fw.cmpl.de.data.Account" table="Account_View" lazy="false" batch-size="10">
<cache usage="read-only"/>
<id name="accountId" type="string" unsaved-value="null" >
<column name="sub_acct_c" not-null="true"/>
</id>

<set name="productList" inverse="true" lazy="false" order-by="sub_acct_c ASC, prime_id_c ASC">
<cache usage="read-only"/>
<key column="sub_acct_c"/>
<one-to-many class="com.gs.fw.cmpl.de.data.Product" />
</set>
</class>

<query name="DE_ACCTS_WITH_TRADES">
<![CDATA[
from Account where accountId in ('00100148', '00100167') order by accountId
]]>
</query>

</hibernate-mapping>



<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="amlusprod" default-lazy="false">

<class name="com.gs.fw.cmpl.de.data.Product" table="Product_View" lazy="false">
<cache usage="read-only"/>

<id name="productId" type="string" unsaved-value="null" >
<column name="prime_id_c" not-null="true"/>
</id>

<set name="tradeList" inverse="true" lazy="false" order-by="prime_id_c ASC">
<cache usage="read-only"/>
<key column="prime_id_c"/>
<one-to-many class="com.gs.fw.cmpl.de.data.Trade" />
</set>


</class>

</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="amlusprod" default-lazy="false">

<class name="com.gs.fw.cmpl.de.data.Trade" table="Trade_View" lazy="false">
<cache usage="read-only"/>
<composite-id>
<key-property name="tradeDate" column="trade_date_d" type="date"/>
<key-property name="tranValue" column="post_amt_c" type="double"/>
<key-property name="tranQty" column="sec_qty_c" type="double"/>
</composite-id>

</class>

</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():

Query namedQuery = session.getNamedQuery(_namedQuery);
namedQuery.setReadOnly(true);
start = System.currentTimeMillis();
Iterator iter = namedQuery.iterate();
end = System.currentTimeMillis();
duration = end - start;
System.out.println("HIBERNATE SELECT NQ DURATION: "+duration);

List acctList = new ArrayList();
start = System.currentTimeMillis();
while ((iter != null) && iter.hasNext())
{
startrow = System.currentTimeMillis();
acct = (Account)iter.next();
end = System.currentTimeMillis();
duration = end - startrow;
System.out.println("HIBERNATE NEXT: "+duration);

cnt++;
if (cnt > 100)
session.clear();
}


Full stack trace of any exception that occurs:

Tue May 17 06:44:20 EDT 2005 WARN [main] SQL Error: -301, SQLState: 07006
Tue May 17 06:44:20 EDT 2005 ERROR [main] DB2 SQL error: SQLCODE: -301, SQLSTATE: 07006, SQLERRMC: 2
Tue May 17 06:44:20 EDT 2005 INFO [main] Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity batch: [com.gs.fw.cmpl.de.data.Trade#<component[tradeDate,tranValue,tranQty]{tra
nValue=11377.46, tranQty=11377.46, tradeDate=03 November 2004}, component[tradeDate,tranValue,tranQty]{tranValue=709500.0, tranQty=15000.0, tradeDate=
25 October 2004}>]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntityBatch(Loader.java:1369)
at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:69)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:350)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:331)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:651)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261)
at org.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:160)
at org.hibernate.collection.PersistentSet.initializeFromCache(PersistentSet.java:96)
at org.hibernate.cache.entry.CollectionCacheEntry.assemble(CollectionCacheEntry.java:35)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.jav
a:126)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:48)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1422)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:271)
at org.hibernate.engine.PersistenceContext.initializeNonLazyCollections(PersistenceContext.java:796)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:215)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1312)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:82)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:350)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:331)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:651)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261)
at org.hibernate.type.EntityType.resolve(EntityType.java:286)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:207)
at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:92)
at org.hibernate.impl.IteratorImpl.next(IteratorImpl.java:119)
at com.gs.fw.gc.ds.tests.DASTest.hibernateSelectNamedQueryTest(DASTest.java:122)
at com.gs.fw.gc.ds.tests.DASTest.testHibernate(DASTest.java:381)
at com.gs.fw.gc.ds.tests.DASTest.main(DASTest.java:410)
Caused by: com.ibm.db2.jcc.c.SQLException: DB2 SQL error: SQLCODE: -301, SQLSTATE: 07006, SQLERRMC: 2
at com.ibm.db2.jcc.c.cf.e(cf.java:1108)
at com.ibm.db2.jcc.c.cf.a(cf.java:897)
at com.ibm.db2.jcc.a.be.n(be.java:548)
at com.ibm.db2.jcc.a.be.i(be.java:228)
at com.ibm.db2.jcc.a.be.c(be.java:54)
at com.ibm.db2.jcc.a.s.c(s.java:53)
at com.ibm.db2.jcc.a.bq.h(bq.java:118)
at com.ibm.db2.jcc.c.cf.i(cf.java:893)
at com.ibm.db2.jcc.c.cg.a(cg.java:1540)
at com.ibm.db2.jcc.c.cg.executeQuery(cg.java:312)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:75)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1239)
at org.hibernate.loader.Loader.doQuery(Loader.java:374)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.loadEntityBatch(Loader.java:1362)
... 37 more
Tue May 17 06:44:20 EDT 2005 INFO [main] Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity batch: [com.gs.fw.cmpl.de.data.Trade#<component[tradeDate,tranValue,tranQty]{tra
nValue=11377.46, tranQty=11377.46, tradeDate=03 November 2004}, component[tradeDate,tranValue,tranQty]{tranValue=709500.0, tranQty=15000.0, tradeDate=
25 October 2004}>]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntityBatch(Loader.java:1369)
at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:69)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:350)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:331)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:651)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261)
at org.hibernate.type.ManyToOneType.assemble(ManyToOneType.java:160)
at org.hibernate.collection.PersistentSet.initializeFromCache(PersistentSet.java:96)
at org.hibernate.cache.entry.CollectionCacheEntry.assemble(CollectionCacheEntry.java:35)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.jav
a:126)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:48)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1422)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:271)
at org.hibernate.engine.PersistenceContext.initializeNonLazyCollections(PersistenceContext.java:796)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:215)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1312)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.loader.entity.BatchingEntityLoader.load(BatchingEntityLoader.java:82)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2461)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:350)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:331)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:651)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:261)
at org.hibernate.type.EntityType.resolve(EntityType.java:286)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:207)
at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:92)
at org.hibernate.impl.IteratorImpl.next(IteratorImpl.java:119)
at com.gs.fw.gc.ds.tests.DASTest.hibernateSelectNamedQueryTest(DASTest.java:122)
at com.gs.fw.gc.ds.tests.DASTest.testHibernate(DASTest.java:381)
at com.gs.fw.gc.ds.tests.DASTest.main(DASTest.java:410)
Caused by: com.ibm.db2.jcc.c.SQLException: DB2 SQL error: SQLCODE: -301, SQLSTATE: 07006, SQLERRMC: 2
at com.ibm.db2.jcc.c.cf.e(cf.java:1108)
at com.ibm.db2.jcc.c.cf.a(cf.java:897)
at com.ibm.db2.jcc.a.be.n(be.java:548)
at com.ibm.db2.jcc.a.be.i(be.java:228)
at com.ibm.db2.jcc.a.be.c(be.java:54)
at com.ibm.db2.jcc.a.s.c(s.java:53)
at com.ibm.db2.jcc.a.bq.h(bq.java:118)
at com.ibm.db2.jcc.c.cf.i(cf.java:893)
at com.ibm.db2.jcc.c.cg.a(cg.java:1540)
at com.ibm.db2.jcc.c.cg.executeQuery(cg.java:312)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:75)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1239)
at org.hibernate.loader.Loader.doQuery(Loader.java:374)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.loadEntityBatch(Loader.java:1362)
... 37 more

Name and version of the database you are using:
DB2 UDB 8.x

The generated SQL (show_sql=true):


Debug level Hibernate log excerpt:


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

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.