-->
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: bug with one-to-many association and composite-id
PostPosted: Wed Oct 29, 2003 7:34 am 
Newbie

Joined: Wed Oct 29, 2003 6:15 am
Posts: 7
Hi,

I used Hibernate 2.0.3.

I have an exception on the method

line 25 : SessionFactory sessions = cfg.buildSessionFactory();

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at net.sf.hibernate.sql.OracleJoinFragment.addJoin(OracleJoinFragment.java:25)
at net.sf.hibernate.loader.OuterJoinLoader.outerJoins(OuterJoinLoader.java:424)
at net.sf.hibernate.loader.AbstractEntityLoader.renderStatement(AbstractEntityLoader.java:47)
at net.sf.hibernate.loader.AbstractEntityLoader.renderStatement(AbstractEntityLoader.java:34)
at net.sf.hibernate.loader.EntityLoader.<init>(EntityLoader.java:35)
at net.sf.hibernate.persister.EntityPersister.postInstantiate(EntityPersister.java:153)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:223)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at TestSchema.main(TestSchema.java:19)


I have an Table with a one-to-many assocaition on a AssociationTable


The Table have one primary key
The AssociationTable have a composite primary key

see mapping :

My Table with the one-to-many association
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="genoplante.cargo.db.transcriptome.hibernate.Molecule_Type"
table="MOLECULE_TYPE"
proxy="genoplante.cargo.db.transcriptome.hibernate.Molecule_Type"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="molecule_type_id"
column="MOLECULE_TYPE_ID"
type="java.lang.Integer"
>
<generator class="uuid.hex">
</generator>
</id>
<set
name="labeled_extract_ctrl_elt"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>

<key
column="MOLECULE_TYPE_ID"
/>

<one-to-many
class="genoplante.cargo.db.transcriptome.hibernate.Labeled_Extract_Ctrl_Elt"
/>
</set>
</class>

</hibernate-mapping>


my AssociationTable

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="genoplante.cargo.db.transcriptome.hibernate.Labeled_Extract_Ctrl_Elt"
table="LABELED_EXTRACT_CTRL_ELT"
proxy="genoplante.cargo.db.transcriptome.hibernate.Labeled_Extract_Ctrl_Elt"
dynamic-update="false"
dynamic-insert="false"
>

<composite-id>
<key-property name="labeled_extract" type="java.lang.Integer" column="LABELED_EXTRACT_ID"/>
<key-property name="control_element" type="java.lang.Integer" column="CTRL_ELT_ID"/>
</composite-id>

<many-to-one
update="false"
insert="false"
column="MOLECULE_TYPE_ID"
name="molecule_type"
class="genoplante.cargo.db.transcriptome.hibernate.Molecule_Type"
cascade="none"
outer-join="auto"
/>
</class>

</hibernate-mapping>


In the method
net.sf.hibernate.sql.OracleJoinFragment.addJoin(...)
I have display the size of the fkColumns and the size of the pkColumns and i obtain
this :

fkColumns.length = 2 and pkColumns.length = 1

and i have display the values :

FK 0 labeled_0_.LABELED_EXTRACT_ID
FK 1 labeled_0_.CTRL_ELT_ID
PK 0 LABELED_EXTRACT_ID

If i remoce the one-to-many association in my table mapping file my script run correctly

Do you have any idea ?

Thank you for your help.


Guillaume


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 9:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hmmmm. we have seen this a few times recently.

The mapping -looks- ok.

Perhaps I broke something in 2.0.3.

Could you submit your mappings + persistent classes to JIRA please? I'll look into this.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 9:52 am 
Newbie

Joined: Wed Oct 29, 2003 6:15 am
Posts: 7
How can I submit my files in the jira ?

I create a new issue of type bug or other ?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 9:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
create a new bug. I'm not convinced its really a bug, but thats the suspicion.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 10:13 am 
Newbie

Joined: Wed Oct 29, 2003 6:15 am
Posts: 7
It's ok

Bug number HB-431 with a tar.gz of my files

Thank you for your help.

Guillaume


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 10:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
The problem was that you had two <one-to-one> mappings from a class with a composite id to a class with a single <id> column. This is obviously incorrect. When I removed these, the mappings compiled correctly.

I also noticed that Hibernate 2.1 throws a friendlier exception, which is good.

Now, notice that the real problem had nothing to do with the mappings you posted here. Please ALWAYS ISOLATE porblems before posting!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2003 10:40 am 
Newbie

Joined: Wed Oct 29, 2003 6:15 am
Posts: 7
Thank and I am sorry for my mistake !


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.