-->
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: Subclass hiding properties of parent class?
PostPosted: Tue Jan 17, 2006 8:20 am 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
I'm using Hibernate 2.1.8, with XDoclet. I have a class, which I'll call Thing, and another class which extends it, which I'll call SubThing. I want to map each of these to their own table. SubThing does not have all the properties of Thing, so I want the SubThing table to have fewer columns.

Now, as it is, when Hibernate updates the schema it gives the 'sub_thing' table all the same columns as 'thing'. I thought perhaps if I overrode the 'get...' methods whose properties I did not need in the subclass, so they just returned null and lacked the XDoclet comments, Hibernate would not create columns for them but this is not the case. How, then, should I suppress these properties so no columns are created for them?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 10:37 pm 
Newbie

Joined: Tue Jan 10, 2006 1:30 pm
Posts: 14
Have you tried something like this?

<class name="Thing" table="THING" >
<property name="thingName" column="THINGNAME"/>

<joined-subclass name="SubThing" table="SUBTHING">
<key column="THING_ID">
<property name="subThingName" column="SUBTHINGNAME"/>
</joined-subclass>

</class>

_________________
Brian


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 6:28 am 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
cokerbl wrote:
Have you tried something like this?

<class name="Thing" table="THING" >
<property name="thingName" column="THINGNAME"/>

<joined-subclass name="SubThing" table="SUBTHING">
<key column="THING_ID">
<property name="subThingName" column="SUBTHINGNAME"/>
</joined-subclass>

</class>


Thanks, I'll investigate that. What I've actually done in the meantime is to refactor the code so that the common stuff is in an abstract class (AbstractThing) which ComplexThing and SimpleThing both extend. It works for this case but isn't really an answer to the general question.


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.