-->
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.  [ 2 posts ] 
Author Message
 Post subject: [PLEASE] Help me with the composite-id
PostPosted: Sun May 16, 2004 6:06 pm 
Newbie

Joined: Sun May 16, 2004 5:45 pm
Posts: 1
Hi all,

i didn't find any solution of my hibernate trouble since the last 3 days. How can i represente that SQL code in hibernate mapping and java code :

create table bundles(idbun not null primary key, etc...)
create table files(idfile not null primary key, etc...)
create table fileperbundle(idbun_fk not null, idfile_fk not null, primary key (idbun_fk, idfile_fk) foreign key idbun references bundles(idbun_fk), etc...)

i think i have to use the composite-id hibernate attribute. i did that :

<class name="Fileperbundle" table="fileperbundle>
<composite-id name="id" class=? (i don't know to put here)>
<key-many-to-one name="idBunFK" class="Bundle" column="idbun" />
<key-many-to-one name="idFileFK" class="File" column="idfile" />
</composite-id>
</class>

is this mapping correct ? and can somebody show me what is the java code of the Fileperbundle class.

Thanks a lot (and sorry for my english)

--
kurk


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2004 7:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
It looks basically OK - issue that exist is that the column attributes for the composite key references look incorrect.

As far as your POJOs use hbm2java to generate the pojos for you from your mapping document. Further if you are having problems with getting the mapping right use Middlegen to create the mapping files from the database. You might not use these tools in the future but they can get you started quickly and have a education side benefit.


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