-->
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: Thoughts about inheritance
PostPosted: Wed Aug 24, 2005 4:45 am 
Newbie

Joined: Wed Mar 16, 2005 11:06 am
Posts: 10
1. "table per class" is not so bad ------------------
The documentation (chapter 10.1.1) and Hibernate in Action tell that "table per class" has the major problem that subclass columns have to be nullable.

But why shouldn't one define a subclass column "not null default X". So superclass entries get the default value assigned and subclasses must not use null for this column.

The only thing not working is "not null default null" to force a user to provide a value. This is only needed when legacy applications or ad hoc queries are working with the database.

What problem is left with "table per class" is that the table is not normalized.



2. Restrict a query to a supertype only possible with "table per class hierarchie" ------------------
There you have an additional property available in HQL with maps to the descriminator value (docu 15.7).
With class A and class B extending A you can retrieve all A excluding all B with
"from A a where a.class = A".

This is not possible with "table per class" (and I think with "table per subclass" neither, I didn't try) because the discriminator value is missing.

But why does Hibernate use the discriminator value here and not something like the table which is available in all kinds of inheritance technique?



3. "select count(*) from supertype" returns strange value -------------------------
It seems to count all items in the different inheritance tables separately.
When using "table per class hierarchy" it returns the correct value.
When using "table per class" it returns a List of Integers with the count in every table.
"table per subclass" not tested.

What sense does this behaviour make? Is it documented somewhere?
So the program code depends on the inheritance technique defined in the mapping files.



I think at least should the documentation point out these behaviours.

Regards
Sebastian


Top
 Profile  
 
 Post subject: Re: Thoughts about inheritance
PostPosted: Wed Aug 24, 2005 5:39 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
sebbo wrote:
1. "table per class" is not so bad ------------------
The documentation (chapter 10.1.1) and Hibernate in Action tell that "table per class" has the major problem that subclass columns have to be nullable.

It doe's not have any problems, just use "CHECK(discriminator <> subclass OR subclassField IS NOT NULL )" constraint


Top
 Profile  
 
 Post subject: Re: Thoughts about inheritance
PostPosted: Wed Aug 24, 2005 5:58 am 
Newbie

Joined: Wed Mar 16, 2005 11:06 am
Posts: 10
baliukas wrote:
sebbo wrote:
1. "table per class" is not so bad ------------------
The documentation (chapter 10.1.1) and Hibernate in Action tell that "table per class" has the major problem that subclass columns have to be nullable.

It doe's not have any problems

But the documentation says so. It should be changed.

Quote:
just use "CHECK(discriminator <> subclass OR subclassField IS NOT NULL )" constraint

That's even better than using a default (if the database supports CHECK).


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.