Here is my point of view both with and without inheritance, because I think that both can be handled the same way - at least when only JPA entities are generated.
Lets take an example : 2 entity classes B and C inheriting from an entity class A. Texo could generate something like this :
@MappedSuperclass
public abstract class BaseA {
@Id
public Long id;
public String nameBaseA;
}
@Entity
// Inheritance mode according to annotation model
@Inheritance(strategy=InheritanceType.JOINED)
public class A extends BaseA {
public String nameA;
}
@MappedSuperclass
public abstract class BaseB extends A {
public String nameBaseB;
}
@Entity
public class B extends BaseB {
public String nameB;
}
@MappedSuperclass
public abstract class BaseC extends A {
public String nameBaseC;
}
@Entity
public class C extends BaseC {
public String nameC;
}
(here attributes called *name in classes are optional, it is just to show how to work in all classes).
I suggest that Texo could generate classes A, B and C once for all. Those classes would be the ones in which the user would manually write his code. Those classes are annotated @Entity, because when the user will use his ORM tool, I guess that he will want to manipulate classes A, B and C, not BaseA, BaseB, and BaseC.
Now, Texo should also generate BaseA, BaseB, and BaseC. Those classes would always be generated. So that the user must not write anything inside. Because of how JPA supports inheritance, those classes have to be annotated @MappedSuperclass.
I tested this with Hibernate, and my schema is generated correctly. I have not gone much far (with relations in mapped supperclasses for example, does this work ?).
Texo would also have to propose an option for this, at package and class levels, because the user may not always want to use this mechanism. If the mechanism is disabled, then Texo should generate entities like it does today.
Well, I don't know how this can be integrated with all the stuff around Texo and JPA (orm.xml, factories relying on EMF, etc...).
This is an implementation proposal. Anyway, I am going to post this in a bugzilla.
Thanks for your time ]]>