Java JPA Polymorphic Many-to-One Mapping
I am trying to map JPA (now using Hibernate). Many-to-one relationship with polymorphic type, but I had no luck. I don't understand why this is not possible, or why I would be forced to declare a specific type in the display. Here's an example:
@MappedSuperclass
class BaseClass {
@Id
long id;
}
class ClassWithList extends BaseClass {
String attribute;
@OneToMany(mappedBy="backPointer")
List<ListClass> list;
}
class ListClass extends BaseClass {
String listItemData;
@ManyToOne
@JoinColumns({
@JoinColumn(name="baseId"),
@JoinColumn(name="baseType"),
})
BaseClass backPointer;
}
Thanks for any advice you can give.
+1
a source to share
1 answer
You have nothing to say for a particular record as it is. I suggest you take a look at TopLink JPA: How to Define Inheritance . This is not applicable for Hibernate.
+1
a source to share