Hi there,
I need to do a choice on annotation overriding in Hibernate Annotation. I do not mean overriding by XML but by annotations.


Here is my based sample
public class A {
 public String getChoice() {}
 public int getAge() {}
}

@Entity
public class B extends A {
 @Column(name="b_name")
 public String getName() {}

 @Transient
 public int getAge() {}
}


@Entity public class C extends B { @Column(name="c_name") public String getName() {} }

Remember that, no annotation on a property means default values.
It seems to me that an annotation should not be overridable in a subclass (this is quite a non sense from a RDBMS perspective), which lead the previous sample to use b_name as a column name. So I will just ignore subclass overriding. Let's call it rule 0.


Now comes the tricky part. Using the XDoclet experience, I currently allow the property of A to be mapped even if A is not an @Entity, so you can"share" the mapping among the different sub entities.
But because of rule 0, you cannot "disable" a mapping (eg A.choice will be mapped), it seems reasonnable that you don't always want the properties of the super class to be mapped.
So what we can do is
1. not mapping the properties of the non @Entity superclasses (age is not mapped because A is ignored)
2. mapping them but not allowing any overriding (except from an XML point of view) (age is mapped becasue B.age is ignored)
3. mapping them and allow subclass overriding up to the root Entity (age is not mapped because B.age override A.age)


This may be quite confusing but I would prefer rule 0 + rule 3 to keep the flexibility. Any opinion?

BTW: the spec does not state this and declare the application using overriding as non portable.

--
Emmanuel Bernard
[EMAIL PROTECTED]
callto://emmanuelbernard

http://www.hibernate.org



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to