Hi, I'm wondering if the following behaviour of Hibernate 2.1.4 is intended, and especially if it is going to stay that way in future versions.
Suppose I have the following abstract base class, which is
NOT mapped:
Code:
public abstract class AbstractFoo {
private AbstractFoo parent;
public AbstractFoo getParent() {
return parent;
}
public void setParent(AbstractFoo parent) {
this.parent = parent;
}
}
Now I have the following subclass, which is mapped:
Code:
public class Foo extends AbstractFoo {
private Long id;
private String name;
// getters/setters for "id" and "name" properties
// no getter/setter for "parent" property here,
// we use getter/setter of superclass
}
This is the mapping:
Code:
<class name="eg.Foo" table="FOO">
<id name="id" column="foo_id">
<generator class="native"/>
</id>
<many-to-one name="parent" class="eg.Foo" column="parent_id"/>
<property name="name"/>
</class>
Now, please note that in the mapping it says that Foo.getParent() will return an instance of Foo, but the actual (inherited) getter returns an instance of AbstractFoo.
In practice, this works quite well and perfectly fits my needs. But I wonder if this behaviour is intended, and if it is going to stay that way in future Hibernate versions.