-->
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.  [ 5 posts ] 
Author Message
 Post subject: one class- multiple tables?
PostPosted: Sun Dec 11, 2005 12:36 pm 
Hi!

New to hibernate, so forgive me if this question is stupid.

I have one class whose data is compromised out of 2 tables, depending on what kind of object it is. (there are more columns in them, but I have execluded them for simplicity)

Table:Merchandise
ID
OrderID
Type
Quantity

Table:TShirtMerchandise
MerchandiseID
Size
Sleeves
Color

Table:BadgeMerchandise
MerchandiseID
Size
BackgroundColor
BackgroundImage
Back

Now, for instance, the
Badge class is compromised of data from BadgeMerchandise and Merchandise table. How do I go about mapping this with NHibernate? Can anyone point me in the right direction?


Top
  
 
 Post subject:
PostPosted: Sun Dec 11, 2005 12:45 pm 
Newbie

Joined: Sun Dec 11, 2005 12:22 pm
Posts: 5
Oh, and sorry for posting as Guest there. :P

_________________
Mattias Petter Johansson


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 11, 2005 9:50 pm 
Newbie

Joined: Wed Dec 07, 2005 12:32 am
Posts: 11
Location: Chennai, India
Hi mattiasjte,
I would suggest sublcassing the merchandise classes into BadgeMerchandise and ShirtMerchandise. To do that, u need to have only onle table called merchandise. But, have a field that will help in distinguishing the type of merchandise. This column should then be set as discriminator in the hbm file. In case you need more details on the hbm, let me know. I shall post it here.

HTH,
~Venki


Top
 Profile  
 
 Post subject: Re: one class- multiple tables?
PostPosted: Sun Dec 11, 2005 10:36 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 11:09 pm
Posts: 23
Hey. If you want to keep the three tables, you will want a joined-subclass (table-per-subclass) mapping.

Just set the subclass key to the MerchandiseID column.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 13, 2005 7:25 pm 
Newbie

Joined: Sun Dec 11, 2005 12:22 pm
Posts: 5
Thank you very much!

_________________
Mattias Petter Johansson


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.