-->
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: Best practise: multi 1:n association to same target entity
PostPosted: Wed Mar 17, 2010 7:33 am 
Newbie

Joined: Wed May 11, 2005 7:16 am
Posts: 9
Hello,
i'm a little bit confused how to model following situation:

I have a entity DescriptionItems which has an attribute Locale to be independet from different languages, and the descritption itself.

Now i have two furter entities:

Entity A: Has a Map of description items called logicalDescritptions and a Map technicalDescriptions

What is the best way to implemnt this relationship? One solution is to implemet a 3rd Entity descriptionsBag to contain the relevant descriptionItems for either logical or technical Descriptions, but i'm afraid that's not the best pratise because i don't wanna implement an extra class only for satisfy hibernate....

Hope for help....
Uli


Top
 Profile  
 
 Post subject: Re: Best practise: multi 1:n association to same target entity
PostPosted: Wed Mar 17, 2010 8:37 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I would map this as follows (using sets instead to maps):

@Entity
public class A
{

@OneToMany()
Set<DescriptionItem> logicalDescriptions = new HashSet<DescriptionItem>();

@OneToMany()
Set<DescriptionItem> tecnicalDescriptions = new HashSet<DescriptionItem>();

}


Top
 Profile  
 
 Post subject: Re: Best practise: multi 1:n association to same target entity
PostPosted: Wed Mar 17, 2010 9:37 am 
Newbie

Joined: Wed May 11, 2005 7:16 am
Posts: 9
Thanx for reply...

Ok..that will produce two join tables, each per association.....

I'll try to find a way to produce only one with the id of the join table in the relevant "A" tables attribute...Is this possible w/o creating a descriptionBag Class?


Top
 Profile  
 
 Post subject: Re: Best practise: multi 1:n association to same target entity
PostPosted: Thu Mar 18, 2010 1:58 am 
Newbie

Joined: Wed Mar 17, 2010 11:24 pm
Posts: 1
best wishes.

_________________
the wire dvd
ncis dvd set
married with children dvd setBuffy The Vampire Slayer seasons dvd
Bones 1-4 dvd


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.