-->
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.  [ 1 post ] 
Author Message
 Post subject: Using bag with composite key ?
PostPosted: Thu Sep 03, 2009 3:30 am 
Newbie

Joined: Thu Sep 03, 2009 3:10 am
Posts: 5
Hello,

I'm working on a project and use hibernate tools (Hibernate 3.0 XML Editor) to generate the entities.
I need it to let me use an existing database in my JEE java code.

I want to add a mapping/list/bag to an entity which contains address info. The simplified database tables looks like this:

Contact
---------------
contactcode (PK)
contacttype (PK)
lastname
firstname
dateofbirth
....

Address
--------------
contactcode (PK)
contacttype (PK)
index (PK)
addressrow

In the database there isnt a FK relation defined, but as you can see this construction allows to add any number of address rows to a contact.
What I want to acomplish is that the contact entity I use in my code contains a address property (as a list or collection) which contains all the address rows. Use SQL you can get the info with an extra select but how do I model this in the hbm.xml?

I tried some things in the contact.hbm.xml file but nothing worked. I did read a lot of documents but cant find an example which matches my situation.

b.t.w. I'm using exclipse with hibernate and hibernate tools.

Anyone got a suggestion ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.