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:
DOGdogID (auto increment)
standardTextID
STANDARD_TEXTstandardTextID (auto increment)
STANDARD_TEXT_DETAILstandardTextDetailId (auto increment)
standardTextID
language
description
Here's sample data to clarify the database design:
DOGdogID-----standardTextID 1...................1
2...................2
STANDARD_TEXTstandardTextID1
2
STANDARD_TEXT_DETAILstandardTextCodeDetailID ---- standardTextID ---- language ---- description1..............................................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*