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: Mapping joined-subclass
PostPosted: Thu Apr 22, 2004 12:48 pm 
Newbie

Joined: Tue Apr 20, 2004 4:02 pm
Posts: 4
As I understand the (excellent!) Hibernate docs, to do a joined-subclass mapping (table-per-subclass mapping), I have to put the entire subclass mapping info inside the parent class mapping file in a joined-subclass element. This isn't just the subclass name, table, and key, but all the subclass properties, too.

When using a common, persistent base class ancestor that handles all the shadow information (versioning, timestamps, etc.), this implies that class mapping file will contain all the subclass keys, properties, etc. In this scenario, there will be one, potentially huge, mapping file for all persistent POJOs. Also, when a new subclass POJO is created, one needs to go back into the parent class mapping file and add all the subclass particulars.

Am I misunderstanding how to map the join-subclass? If not, this all has a distinctly non-OO feel about it, kind of like having to modify a base class every time a new subclass is created.

Can I achieve what appear to be the advantages of the join-subclass (i.e. cascading reads/updates/deletes of the ancestor data) while maintaining a separate mapping file for each POJO without manually managing all the ancestor persistence aloing with the subclass persistence?

Sorry if the answer is obvious; I'm just starting to explore Hibernate's capabilities.

All in all, Hibernate seems to be a truly wonderful creation! My hat's off to Gavin and Hibernate's contributors.

_________________
Jack


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 1:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
you can use

<joined-subclass extends="...">

as a subelement of <hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 1:25 pm 
Newbie

Joined: Tue Apr 20, 2004 4:02 pm
Posts: 4
I actually expected there would an "extends" attribute to the joined-subclass element, but the Hibernate 2.1.2 Reference docs don't mention it (p.37). It just describes nesting the joined-ubclass element inside the class element of the parent class.

However, now that you mention it, I see that the DTD allows the joined-subclass element to be nested inside hibernate-mapping.

I'll give it a try. Thanks a lot!

_________________
Jack


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.