-->
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: ManyToMany using Hib/JPA Annotations
PostPosted: Wed Jan 27, 2010 4:07 pm 
Newbie

Joined: Wed Jan 27, 2010 3:53 pm
Posts: 1
Hello All,

I've run across a problem that I'm having a little trouble conceptualizing how I'd implement a solution for using Hib/JPA annotations. The database model that we're looking to achieve is one that contains a join table with a composite key composed of two foreign keys and a third column (we'll call this "type"). So, any combination of entity X, Y, and "type" Z is unique.

A simplified example of how we'd want to use this would be to have a Person object that can have multiple Address objects, but the combination of an Address and it's type is unique. My conceptualization fails in that what we're looking for is the following:

class Person
Set<Address+type> addresses

class Address
Set<Person>

Using either the Address or the "type" as a key in a Map is not sufficient, since it wouldn't ensure uniqueness between the all three variables (i.e. the three-way composite key).

I've tried several permutations of @ManyToMany, @JoinTable, and @MapKey/@MapKeyManyToMany, but haven't been able to get this one right. Any thoughts?

Thanks in advance!


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.