-->
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: Association mapping - 1 class to 3 tables.
PostPosted: Tue Sep 22, 2009 4:00 pm 
Newbie

Joined: Thu Sep 17, 2009 9:31 am
Posts: 10
Hey guys. I've read lots on association mapping, understood most, but got lost and am overwhelmed. Perhaps someone can shed some light?

I've got three tables in my database that I'm working with:

DOG
dogID (auto increment)
standardTextID

STANDARD_TEXT

standardTextID (auto increment)

STANDARD_TEXT_DETAIL

standardTextDetailId (auto increment)
standardTextID
language
description

Here's sample data to clarify the database design:

DOG
dogID-----standardTextID
1...................1
2...................2

STANDARD_TEXT
standardTextID
1
2

STANDARD_TEXT_DETAIL
standardTextCodeDetailID ---- standardTextID ---- language ---- description
1..............................................1....................."en"............."brownDogENGLISH"
2..............................................1....................."fr".............."brownDogFRENCH"
3..............................................1....................."de"............."brownDogGERMAN"
4..............................................2....................."en"............."redDogENGLISH"
5..............................................2....................."fr:.............."redDogFRENCH"

I have ONE class that I want to map, nammed "Dog".

Code:
public class Dog {
   private int ID;
   private Map<Locale, String> descriptions;

   //getters and setters
   
}


I have seem a lot of examples and documentation on using the <join> element to reference a table from the Dog mapping. The problem is occuring because the actual DATA I need to populate into the Dog class exists in the STANDARD_TEXT_DETAIL table, which is two layers away from the DOG table.

When I get a Dog with ID = 1, it should populate the Dog class as follows (excuse the pseudo code):

Dog [ID = 1, { (English, "brownDogENGLISH"), (French, "brownDogFRENCH"), (German, "brownDogGerman") } ]

I know I have to set up a <map> element, but since some of the data is two "layers" away from base table, I'm not sure how to use it correctly.

Any suggestions as to an approach I can take? I could not find an example of when someone had one class to reference three separate tables (two are nested references).

This is already getting a little confusing (as is my problem itself). Anyone? *sigh*


Top
 Profile  
 
 Post subject: Re: Association mapping - 1 class to 3 tables.
PostPosted: Tue Sep 29, 2009 6:34 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 6:39 am
Posts: 44
Location: Mumbai, India
Refer this.

http://docs.jboss.org/hibernate/core/3. ... leperclass

_________________
Thx,
Murugesan.
Web: http://www.murugesanpitchandi.com


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.