Reputation: 904
I'm building an application in Java with the Play 2 framework and ebean ORM.
I have an entity class Person
that is related to several entity classes with the supertype Certificate
, which is an abstract
@MappedSuperclass
. Currently, I'm creating a relationship for each subclass, like so:
public class `Person` extends Model {
// elided...
@OneToMany
public List<SubType1> subType1s;
@OneToMany
List<SubType2> subType2s;
// elided...
}
and the subclasses look like this:
public class SubTypeGeneric {
// elided...
@ManyToOne
public Person person;
// elided...
}
What I want to know is this: is it possible to group the subclass entities lists in Person
together into a single superclass list, like so:
public class `Person` extends Model {
// elided...
@OneToMany
public List<SuperType> superTypes;
// elided...
}
Upvotes: 0
Views: 893
Reputation: 691635
No, it's not possible. An association is between entities, not MappedSuperclasses. And if you have a OneToMany can be the inverse association of only one ManyToOne.
If you want that, then Certificate should be annotated with @Entity, and should contain the ManyToOne association with Person instead of all the subclasses.
Upvotes: 1