-->
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.  [ 8 posts ] 
Author Message
 Post subject: EBUG JDBCExceptionReporter:63 - could not initialize a colle
PostPosted: Thu Apr 20, 2006 9:31 pm 
Newbie

Joined: Thu Apr 06, 2006 8:07 pm
Posts: 5
Hi all,
I am very new to hibernate and I ran into this problem "DEBUG JDBCExceptionReporter:63 - could not initialize a collection: [com.genuitec.person.Person.events#1] [select events0_.PERSON_ID as PERSON1_1_, events0_.EVENT_ID as EVENT2_1_, events1_.EVENT_ID as EVENT1_0_, events1_.TITLE as TITLE1_0_, events1_.EVENT_DATE as EVENT3_1_0_ from PERSON_EVENTS events0_ inner join EVENTS events1_ on events0_.EVENT_ID=events1_.EVENT_ID where events0_.PERSON_ID=?]" when an A unidirectional Set-based association

When I tried to
Transaction tx = session.beginTransaction();
Person aPerson = (Person)session.load(Person.class,personId);


Events aEvent = (Events)session.load(Events.class,eventId);
System.out.println("loaded person: " + aPerson.getPersonId() + ", loaded event: " + aEvent.getEventId());
/** This is where it starts failing. I expect it to create a new row in PERSON_EVENTS table **/
aPerson.getEvents().add(aEvent);
tx.commit();
Note: I have data on both PERSON and Event tables
My tables Desc:

SQL> desc person
Name Null? Type
------------------------------- -------- ----
PERSON_ID NOT NULL NUMBER(11)
AGE NUMBER
FIRSTNAME VARCHAR2(50)
LASTNAME VARCHAR2(50)

SQL> desc events
Name Null? Type
------------------------------- -------- ----
EVENT_ID NOT NULL NUMBER(11)
TITLE VARCHAR2(255)
EVENT_DATE DATE

SQL> desc person_events
Name Null? Type
------------------------------- -------- ----
PERSON_ID NUMBER
EVENT_ID NUMBER

My Person.hbm.xml defination is

<hibernate-mapping package="com.genuitec.person">

<class name="Person" table="PERSON">

<id name="personId" column="PERSON_ID">
<generator class="increment"/>
</id>
<property name="age" column="AGE" type="long" />
<property name="firstname" column="FIRSTNAME" type="string" />
<property name="lastname" column="LASTNAME" type="string" />
<set name="events" table="PERSON_EVENTS">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="com.genuitec.events.Events"/>
</set>


Please help me to find what's the issue is.

Thanks a bunch.

Binh Tran.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 20, 2006 9:58 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Is there a nested exception? There should be an SQLException with more information about the problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 1:05 pm 
Newbie

Joined: Thu Apr 06, 2006 8:07 pm
Posts: 5
Thanks for your help in advance. Below is the whole net exception
16:36:38,812 DEBUG JDBCExceptionReporter:63 - could not initialize a collection: [com.genuitec.person.Person.events#1] [select events0_.PERSON_ID as PERSON1_1_, events0_.EVENT_ID as EVENT2_1_, events1_.EVENT_ID as EVENT1_0_, events1_.TITLE as TITLE1_0_, events1_.EVENT_DATE as EVENT3_1_0_ from PERSON_EVENTS events0_ inner join EVENTS events1_ on events0_.EVENT_ID=events1_.EVENT_ID where events0_.PERSON_ID=?]
java.sql.SQLException: ORA-00933: SQL command not properly ended

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1819)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2015)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:395)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:339)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1434)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:99)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:61)
at org.hibernate.collection.PersistentSet.add(PersistentSet.java:158)
at com.genuitec.test.Test.addPersonToEvent(Test.java:112)
at com.genuitec.test.Test.main(Test.java:48)
16:36:38,828 WARN JDBCExceptionReporter:71 - SQL Error: 933, SQLState: 42000
16:36:38,828 ERROR JDBCExceptionReporter:72 - ORA-00933: SQL command not properly ended

org.hibernate.exception.GenericJDBCException: could not initialize a collection: [com.genuitec.person.Person.events#1]
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1441)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:99)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:61)
at org.hibernate.collection.PersistentSet.add(PersistentSet.java:158)
at com.genuitec.test.Test.addPersonToEvent(Test.java:112)
at com.genuitec.test.Test.main(Test.java:48)
Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1819)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2015)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:395)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:339)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1434)
... 9 more


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 23, 2006 7:00 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Looks like we're going to need the sql, too. Your base exception, "Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended", tells us where to look, but you haven't included what it is we need to look at. Can you post the SQL too? In your hibernate.cfg.xml, add these lines:
Code:
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.format_sql">true</property>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 4:04 am 
Newbie

Joined: Thu Apr 06, 2006 8:07 pm
Posts: 5
Thanks a lot for your help. Below is the SQL generated by Hibernate. When I cut and paste this querry direct to Oracle and I get the same error. What does it tell me?.
Many thanks.

01:08:14,203 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
01:08:14,203 DEBUG SQL:346 -
select
events0_.PERSON_ID as PERSON2_1_,
events0_.EVENT_ID as EVENT1_1_,
events1_.EVENT_ID as EVENT1_1_0_,
events1_.TITLE as TITLE1_0_,
events1_.EVENT_DATE as EVENT3_1_0_
from
PERSON_EVENTS events0_
left outer join
EVENTS events1_
on events0_.EVENT_ID=events1_.EVENT_ID
where
events0_.PERSON_ID=?
Hibernate:
select
events0_.PERSON_ID as PERSON2_1_,
events0_.EVENT_ID as EVENT1_1_,
events1_.EVENT_ID as EVENT1_1_0_,
events1_.TITLE as TITLE1_0_,
events1_.EVENT_DATE as EVENT3_1_0_
from
PERSON_EVENTS events0_
left outer join
EVENTS events1_
on events0_.EVENT_ID=events1_.EVENT_ID
where
events0_.PERSON_ID=?
01:08:14,218 DEBUG AbstractBatcher:424 - preparing statement
01:08:14,359 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
01:08:14,359 DEBUG AbstractBatcher:470 - closing statement
01:08:14,375 DEBUG JDBCExceptionReporter:63 - could not initialize a collection: [com.genuitec.person.Person.events#1] [select events0_.PERSON_ID as PERSON2_1_, events0_.EVENT_ID as EVENT1_1_, events1_.EVENT_ID as EVENT1_1_0_, events1_.TITLE as TITLE1_0_, events1_.EVENT_DATE as EVENT3_1_0_ from PERSON_EVENTS events0_ left outer join EVENTS events1_ on events0_.EVENT_ID=events1_.EVENT_ID where events0_.PERSON_ID=?]
java.sql.SQLException: ORA-00933: SQL command not properly ended

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:643)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1819)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2015)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:395)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:339)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1676)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:183)
at org.hibernate.collection.PersistentSet.add(PersistentSet.java:165)
at com.genuitec.person.AbstractPerson.addToEvent(AbstractPerson.java:143)
at com.genuitec.person.AbstractPerson$$FastClassByCGLIB$$340fa1bd.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:161)
at com.genuitec.person.Person$$EnhancerByCGLIB$$a086b8ae.addToEvent(<generated>)
at com.genuitec.test.Test.addPersonToEvent(Test.java:101)
at com.genuitec.test.Test.main(Test.java:40)
01:08:14,375 WARN JDBCExceptionReporter:71 - SQL Error: 933, SQLState: 42000
01:08:14,375 ERROR JDBCExceptionReporter:72 - ORA-00933: SQL command not properly ended


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 2:37 pm 
Newbie

Joined: Thu Apr 06, 2006 8:07 pm
Posts: 5
Hi tenwit ,

I just found out that Oracle does not support "LEFT OUTER JOIN" keyword in the but it only support table1.id = table2.id(+). How can I tell Hibernate to get rid of "LEFT OUTER JOIN" keyword?.

Many thanks,

Binh.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 2:40 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Have you specified the configuration property in your config file

<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

LEFT OUTER JOIN is supported by Oracle and verified it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 6:08 pm 
Newbie

Joined: Thu Apr 06, 2006 8:07 pm
Posts: 5
Thanks for the help. It works for me after I switched from Oracle 8i to Oracle 10g. It seems like Oracle 8i does not support it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.