-->
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.  [ 3 posts ] 
Author Message
 Post subject: Using discriminator to join to different table
PostPosted: Thu Apr 22, 2010 5:19 am 
Newbie

Joined: Tue Jul 21, 2009 1:46 am
Posts: 5
My aim is to use a discriminator on the basis of field bid_item_type_id to determine which table to join to, to retrieve date using the implicit foreign key in bid_item_id. Is this possible using disciminator in hibernate? If so, can someone please help?!

Code:
Table Structure:
Field                                 Type     
bid_id                               bigint(20) NOT NULL
bid_bill_id                          bigint(20) NOT NULL
bid_item_id                        bigint(20) NULL
bid_item_type_id                bigint(20) NOT NULL
bid_disc_amt                     double NULL
bid_is_disc_in_percent        tinyint(1) NULL
bid_qty                            decimal(10,0) NULL
bid_total_amt                    double NULL


Top
 Profile  
 
 Post subject: Re: Using discriminator to join to different table
PostPosted: Thu Apr 22, 2010 6:05 am 
Regular
Regular

Joined: Tue Feb 24, 2004 11:42 am
Posts: 56
can you provide a bit more details what you are trying to achieve


Top
 Profile  
 
 Post subject: Re: Using discriminator to join to different table
PostPosted: Thu Apr 22, 2010 6:42 am 
Newbie

Joined: Tue Jul 21, 2009 1:46 am
Posts: 5
Depending on the value of bid_item_type_id, bid_item_id may be the id of a product, or a service or a package. I need to decide which table to join to to retrieve the remaining entity data based on the value of bid_item_type_id.

I have so far concluded that this is not possible directly, so I'm creating subclasses for each instead, and setting the value using discriminator. Seems to be my easiest option.


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