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.  [ 1 post ] 
Author Message
 Post subject: How does this happen? Mixed class and tables
PostPosted: Tue Mar 04, 2008 3:22 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:45 am
Posts: 46
Consider this hierarchy:

In Java

Code:
                                  Party
                    Business            Individual
              Client     SPBusiness       SPIndividual
          SPClient

SO, we have a class hierarchy above.

We wanted to place Client and SPClient from Party,Business, SPBusiness,Individual, SPIndividual and place them in separate tables.

The reason we extend Business for Client is simply for re-use.

So, our hibernate mapping class defines Party, and subclasses Business,Individual,SPBusiness and SPIndividual, with discriminators to table PARTY

We then mapped Client as a separate class, along with its descendents to a table CLIENTS. We reproduce the mappings in Client (the attributes, etc) that also appear in Business and Party.

So, all is well, we store data, it goes in the correct place

But, now if we do an HQL "Select from Business", hibernate will actually return the union of all objects from both tables. Even though our mapping for Client does not live in the Business hierarchy, hibernate somehow "determines" that Client extends Business, and gives me all the clients.

Does this make sense? Can anybody tell me how to prevent this, how to separate or break this hierachy? or do i have to move code from Party and Business into Client and maintain it separately?

_________________
Please rate this reply if it helps!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.