-->
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.  [ 7 posts ] 
Author Message
 Post subject: Sub-classing a joined-subclass
PostPosted: Fri Jul 16, 2004 11:48 am 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
A <--- B
B extends A as joined-subclass

B<----B1
B<----B2
B<----B3

B1, B2 and B3 are subclasses of B. i'm trying to get the entire B hierarchy into a single table (table per-hierarchy with a discriminator).

since B is already a subclass it has the tag

Code:
<joined-subclass name="B">


now where do i put the discriminator since

Code:
<joined-subclass name="B" discriminator-value="subType">


is not supported

thanks
ravi


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 12:07 pm 
Regular
Regular

Joined: Thu Jul 08, 2004 1:21 pm
Posts: 68
Location: Recife - Pernambuco - Brazil
Hi, i'm get the same problem because the Hibernate DTD does not permit that a joined-subclass have a subclass witch is the way to use a single table per-hierarchy with a discriminator value. Anyone knows how to solve it?

Details:
Hibernate Version: 2.1.4, 02. June 2004
Class headers with XDoclet Tags:
Code:
/**
* @since 18/07/2004
* @version 0.1
*
* @hibernate.class discriminator-value="U"
*                  proxy="br.ufpe.scacin.model.People"
*                  table="SCACIN_PEOPLE"
*/
public class People implements Identifiable {...}

Code:
/**
* @since 18/07/2004
* @version 0.1
*
* @hibernate.joined-subclass-key column="USER_ID"
*
* @hibernate.joined-subclass proxy="br.ufpe.scacin.model.User"
*                            table="SCACIN_USER"
*
*/
public class User extends People {...}

Code:
/**
* @since 18/07/2004
* @version 0.1
*
* @hibernate.subclass discriminator-value="A"
*                     proxy="br.ufpe.scacin.model.Administrator"
*/
public class Administrator extends User {...}

In the Administrator class, course, the tags does not work and the class is not mapped.

Thanks by any helps.

_________________
Marcos Silva Pereira
http://blastemica.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can't mix sublcass and joined-subclass


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 1:22 pm 
Regular
Regular

Joined: Thu Jul 08, 2004 1:21 pm
Posts: 68
Location: Recife - Pernambuco - Brazil
michael wrote:
You can't mix sublcass and joined-subclass

Thanks, michael, I know this, I read the DTD. ;-)

But, what is the best approach in this case? I'm thinking in change the relationship between People and User, maybe composition instead inheritance. But this imply make changes on the database and I could not make it. So, what you suggest?

valeuz...

_________________
Marcos Silva Pereira
http://blastemica.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 1:44 pm 
Regular
Regular

Joined: Thu Jan 29, 2004 10:34 am
Posts: 52
Location: Austin, TX
for all the subclasses that i intially wanted to put in a single table, i now went with declaring everything as a joined-subclass. it may be a minor performace issue but that depends only how many subclasses you have.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 3:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate3 solves this by allowing you to mix <subclass> and <join>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 09, 2005 5:52 am 
Beginner
Beginner

Joined: Thu Oct 16, 2003 7:30 am
Posts: 21
Location: Brussels
So B is mapped as a <subclass/> of A with a <join/> in it, resulting in tableA and tableB, with tableB having a foreign key to tableA. If now B1, B2 and B3 are mapped to different tables tableB1, tableB2 and tableB3, everything works fine for me with Hibernate 3.0 final.

If, however, I want to map the fields declared by B1 to the same table tableB that was used for class B, Hibernate will try to insert 2 rows into tableB (one for the B attributes and one for the B1 attributes) when saving an object of class B1.

When selecting the data for an object of class B1 Hibernate is doing a join between tableA, tableB and tableB again, making me think that the Hibernate code does not take into account the fact that the joins in a subclass and a subclass of that subclass can make use of a <join/> to the same table.

Is this a bug, a feature request, or just plain nonsense?

Johan.


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