-->
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.  [ 4 posts ] 
Author Message
 Post subject: XDoclet - one-to-many VS composite keys
PostPosted: Tue Sep 26, 2006 2:46 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
I'm trying to map a one-to-many relation.

the point is I'm sending a composite pk from the one to the many side.

On the many side, I can map both PK columns in a single XDoclet TAG.

But I can't (actually nobody here can) figure out how to send both columns from the one side.


I'm using an @hibernate.set where the columns are declared as:
@hibernate.composite-key
column=<column name>
@hibernate.composite-key
column=<column2 name>

But the second one will never be mapped to the hbm.xml file by the ant.

Can someone teach us how to build this one-to-many-with-a-composite-key in the pojos? And tag it in a way it will be mapped to the hbm.xml file by the ant?

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 26, 2006 8:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
From memory YMMV.

@hibernate.set lazy=true
@hibernate.collection-key column=col1
@hibernate.collection-key column=col2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 8:43 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
Thanks. Actually, I found out that the ant won't build the relation correctly from that statment. It'll put only one of the two columns in the hbm.

I read in a tutorial I found that it should be:

@hibernate.collection-key
@hibernate.collection-key-column
name="NAMEOFTHECOLUMN"
@hibernate.collection-key-column
name="NAMEOFTHEOTHERCOLUMN"

At least it works with this one. But somehow the ant that builds the schema (and the tables in the oracle base) is pointing out it can't find the class's PK
and, acording to the references I have, everything should be right.

The pk POJO has the hash and equals it needs, and also the path the program claims it can't find the file into is right too.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 27, 2006 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Traditionally, only separate composite key classes are supported. Integrated is not. Obvious, hibernat expects the order to be the same as well.


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