-->
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: union-subclass and discriminator
PostPosted: Tue Jul 19, 2005 10:36 pm 
Newbie

Joined: Tue Jul 19, 2005 10:04 pm
Posts: 2
Hi,

hibernate 3.0 (DB oracle 9i),

we are working on a requirement that every class below a particular class in the hierarchy must be collapsed into one table.

For this I am trying to use discriminator with union subclass

Suppose in model, class B inherits from class A and class C inherits from B.

I want to create tables only for A and B. Table for B should have all the columns of A as well. (avoiding join for performance reason).

In this case the mapping for B should be union-subclass of A. For C it should be subclass of B with discriminator. Mapping file should be like this.

<class name = "A" table="A">
...
<union-subclass ="B" table="B" discriminator-value = "b">
<discriminator column="value_type" type="string" />
...
<sub-class name="C" discriminator-value="c">
..
</subclass>
</union-subclass>
</class>


I am getting a mapping error. Hibernate doesn't allow me to do such a mapping.

how do I resolve this ?

thanks
--jaideep


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 12:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You cannot do this. Use implicit polymorphism at the top level, and then standard <subclass> hierarchies.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 2:27 am 
Newbie

Joined: Tue Jul 19, 2005 10:04 pm
Posts: 2
Is there any particular reason why hibernate doesn't allow us to do this ?

How do we run a query like select * from A using this approach without an union ? - since it will not return objects in B .

-- jaideep


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.