-->
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: Property metadata returns type over the overriden property
PostPosted: Fri Dec 16, 2005 2:14 am 
Beginner
Beginner

Joined: Fri Nov 04, 2005 3:51 pm
Posts: 32
Hibernate version:3.1

Code:
<class name="School">
  <many-to-one name="person" class="Person" column="person_id"/>
  <subclass name="Room">
    <many-to-one name="person" class="Teacher" column="person_id" insert="false" update="false"/>
  </subclass>
</class>


As you can see, I'm overriding the "person" property in the subclass. Everything is the same on the property element, exept the many-to-one class is different than the one in its superclass.
Room is a subclass of School.
Teacher is a subclass of Person.

My first question is, in general, is it ok do this or is it considered evil?

Secondly, the problem I'm having is with the metadata. When I try to programmaticaly get the type of the "person" property on Room from PersistentClass.getProperty("person").getReturnedClass() , it tells me that it is of type "Person" rather than "Teacher" (it's returning the one from the superclass). Is there a way to get it to return "Teacher"?

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 3:29 am 
Beginner
Beginner

Joined: Fri Nov 04, 2005 3:51 pm
Posts: 32
hmm.. looks like it's available via a different part of the API.

getClassMetadata(clazz).getPropertyType(propName).getReturnedClass()

Still don't undertand why the other class doesn't work, but this gives me what I want.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.