-->
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: Strange Subclassing Question
PostPosted: Mon Dec 22, 2003 6:34 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
Hello,

I'm using the "table per class hierarchy" strategy. I have a strange question about inherited properties. It's a long explanation as to WHY I want to do this, but the question itself is straightforward:

Can I override ride a property in a subclass's mapping with a DIFFERENT column name than it's superclass?

For example:

[class:Animal]
<property name="color" column="COLOR1"/>
[subclass:Dog]
<property name="color" column="COLOR2"/>
[subclass:Cat]
<property name="color" column="COLOR3"/>

Does anyone know if:

1) this will work at all,

2) if queries on the subclasses for the "color" property work as expected.. pulling from COLOR1, COLOR2, COLOR3 depending on the row/subclass?

I understand there is no apparent reason for wanting to do this, but I have a very odd cirumstance to deal with! :)

Thanks,

Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 9:15 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
Hibernate is the best!

I tested it out and answered my question. Hibernate does indeed support a subclass overriding a parent property with a completely different column name! And, when you query the superclass using HQL, hibernate actually creates two completely different queries so that it gets the column names right! It then must combine these queries into one result behind the scenes.

Perfect!

Ryan


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.