-->
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.  [ 7 posts ] 
Author Message
 Post subject: composite-id bug ?
PostPosted: Wed Mar 10, 2004 10:59 am 
Newbie

Joined: Tue Aug 26, 2003 2:49 pm
Posts: 11
Here is a piece of my mapping file:


<class name="Type1" table="TST.ENT">
<composite-id name="CompsiteId" class="TestCompositeId" unsaved-value="any">
<key-property name="Id1" column="_ID_1" type="string"/>
<key-property name="Id2" column="_ID_2" type="string"/>
<key-property name="Key" column="_KEY" type="string"/>
<key-many-to-one name="myObj" class="MyObj" column="UID"/>
</composite-id>

<bag name="links" table="TST.Link" lazy="true" cascade="none" inverse="true">
<key>
<column name="_ID_1" not-null="true"/>
<column name="_ID_2" not-null="true"/>
<column name="_KEY" not-null="true"/>
</key>
<one-to-many class="Type2"/>
</bag>
<property name="ts" column="TS" type="java.sql.Timestamp" not-null="true"/>
</class>

<class name="Type2" table="TST.Link">
<composite-id name="CompsiteId" class="Test2CompositeId" unsaved-value="any">
<key-property name="Id1" column="_ID_1" type="string"/>
<key-property name="Id2" column="_ID_2" type="string"/>
<key-property name="Key" column="_KEY" type="string"/>
<key-many-to-one name="myObj" class="MyObj" column="UID"/>
</composite-id>

<bag name="ents" table="TST.ENT" lazy="true" cascade="none" inverse="true">
<key>
<column name="_ID_1" not-null="true"/>
<column name="_ID_2" not-null="true"/>
<column name="_KEY" not-null="true"/>
</key>
<one-to-many class="Type1"/>
</bag>

<property name="ts2" column="TS2" type="java.sql.Timestamp" not-null="true"/>
</class>



When I have a Type1 object and I use Type1.getLinks(), I have these traces back:

- SQL Error: 1006, SQLState: 72000
- ORA-01006: bind variable does not exist

- SQLException initializing collection
java.sql.SQLException: ORA-01006: bind variable does not exist

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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:71)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:551)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:140)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:102)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:151)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:64)
at net.sf.hibernate.collection.Bag.iterator(Bag.java:261)
............... etc
- Failed to lazily initialize a collection
java.sql.SQLException: ORA-01006: bind variable does not exist
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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:71)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:551)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:140)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:102)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:151)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:64)
at net.sf.hibernate.collection.Bag.iterator(Bag.java:261)
..... etc
rethrown as
net.sf.hibernate.JDBCException: SQLException initializing collection: ORA-01006: bind variable does not exist
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2900)
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:151)
at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:64)
at net.sf.hibernate.collection.Bag.iterator(Bag.java:261)
at com.processia.vpm.data.Model.cloneEntity(Model.java:232)
at com.processia.vpm.data.Model.addEntityFromExistingEntity(Model.java:81)
at com.processia.vpm.logic.LifeCycleManager.reviseModel(LifeCycleManager.java:510)
at com.processia.vpm.logic.LifeCycleManager.revisePart(LifeCycleManager.java:77)
at com.alstom.vpm.test.AlstomLifeCycleManagerTest.testReviseWithEntityMML(AlstomLifeCycleManagerTest.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
Caused by: java.sql.SQLException: ORA-01006: bind variable does not exist
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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:71)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:551)
at net.sf.hibernate.loader.Loader.doFind(Loader.java:140)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:602)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:102)
at net.sf.hibernate.impl.SessionImpl.initialize(SessionImpl.java:2897)
... 23 more



Any help will be it welcome.

Moha,


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 11:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, you are right. There is an obvious bug in your mapping. Collection foreign <key>s must have the same number of columns as the primary key of the owning class. Clearly.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 12:23 pm 
Newbie

Joined: Tue Aug 26, 2003 2:49 pm
Posts: 11
Thanks for your respond gavin.
But I'd like Type1.getLinks() return all Type2 objects, whatever UID value is.
Do you have an idea to do that ?

Moha,


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 12:43 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
<class name="Type1" table="TST.ENT">
<composite-id name="CompsiteId" class="TestCompositeId" unsaved-value="any">
<key-property name="Id1" column="_ID_1" type="string"/>
<key-property name="Id2" column="_ID_2" type="string"/>
<key-property name="Key" column="_KEY" type="string"/>
<key-many-to-one name="myObj" class="MyObj" column="UID"/>
</composite-id>

<bag name="links" table="TST.Link" lazy="true" cascade="none" inverse="true">
<key>
<column name="_ID_1" not-null="true"/>
<column name="_ID_2" not-null="true"/>
<column name="_KEY" not-null="true"/>
</key>
<one-to-many class="Type2"/>
</bag>
<property name="ts" column="TS" type="java.sql.Timestamp" not-null="true"/>
</class>


Quote:
whatever UID value is
what does that mean?

Have you read all the docs? [/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
"whatever UID value is " what do you want to do exactly?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 2:35 pm 
Newbie

Joined: Tue Aug 26, 2003 2:49 pm
Posts: 11
When I call Type1.getLinks(), I


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 6:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use a query, not a collection mapping.


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