-->
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.  [ 2 posts ] 
Author Message
 Post subject: joined-subclass with a discriminator column
PostPosted: Fri Mar 24, 2006 3:40 am 
Newbie

Joined: Wed Jul 20, 2005 7:59 pm
Posts: 3
Hibernate version: 3.0.5

So, I have a three tiered inheritance hierarchy:

I start with base class A which has its own db table. Class B subclasses A, has its own db table, and is mapped using <joined-subclass>. Classes C and D subclass B, but have no additional fields and therefore do not need their own additional db tables. It makes sense that the inheritance relationship between class B and its subclasses C and D should be mapped with a table-per-hierarchy style, which would require a discriminator column in class B.

This is where my problem comes in. Remember that class B is a <joined-subclass> because it extends class A. The mapping DTD does not allow <discriminator> inside of a <joined-subclass>, and my project won't deploy when I put one in. This prevents me from mapping classes C and D in a table-per-hierarchy with class B.

Is forbidding <discriminator> in <joined-subclass> simply an oversight or is there a technical reason for this? Is there a solution to this problem that I am overlooking? Please note that I know I can make separate tables for classes C and D that contain only ids in order to make C and D joined-subclasses as well, but this fills my db with dummy tables and I'd naturally like to avoid that.

Thanks much for you consideration in this issue!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 4:23 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

we had the same problem.
Hibernate does not support the mixing of inheritance strategies.
There are two solutions to this:

1. Write DTO classes for B,C and D. These can be mapped by discriminator
hierarchy. And map class A to its table directly. You certainly have more to do manually when loading and saving.

2. write you own persister class. You can look at JoinedSubclassEntityPersister for a starter. This is certainly difficult.

Hope this helps.

_________________
dont forget to rate !


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