-->
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: Modelling Question
PostPosted: Tue Jan 13, 2004 6:24 pm 
Newbie

Joined: Fri Dec 12, 2003 2:12 am
Posts: 16
I was looking at our schema last night and this morning, and noticed something that might not map well in Hibernate.

It will probably be easiest to give an example.

Lets say we have a main table called "main_table". There are a couple of foreign keys from two lookup-tables in main_table (lets call them "lookup_one" and "lookup_two"). Both lookup-tables have composite primary keys comprised of an ID and a language_id.

table lookup_one:

lookup_one_id
language_id
lookup_one_description


table lookup_two:

lookup_two_id
language_id
lookup_two_description


main_table:

main_table_id
lookup_one_id
language_id
lookup_two_id


As you can see, language_id only shows up once, even though it is part of the primary-key for the two lookup tables. Oracle lets you do this, and there are some advantages; you want all data in the main table to have the same language.

In order to model this in Hibernate, it would seem to me that you would want to create a primary-key class for each lookup, and it would have the two primary key items.

So now you have two classes inside the main_table class (one for each foreign-key back to the lookup tables), and each class has it's own language id.

We have this all throughout our schema; I didn't design it, and we can't change it without spending 6 months of development time, which will not happen, so please don't respond, "Change your schema".

Is this going to be a major stumbling block?

Thanks,
David


Top
 Profile  
 
 Post subject: Yes
PostPosted: Tue Jan 13, 2004 6:43 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Based on my experience trying to do something similar I would say yes, it could turn into a real pain.

I never used seperate classes for my PK's and instead tried to use composite-id stuff directly for the children which may have been my problem.

What would your domain model and mappings look like of this?

Would you have one-to-one's from the main_table to the lookups?


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.