我想与解放者一道坚持我的灵感:
@Entity
@Table(name = "zoo")
public class Zoo {
@OneToMany
private Set<Animal> animals = new HashSet<Animal>();
}
// Just a marker interface
public interface Animal {
}
@Entity
@Table(name = "dog")
public class Dog implements Animal {
// ID and other properties
}
@Entity
@Table(name = "cat")
public class Cat implements Animal {
// ID and other properties
}
当我试图维持动物园时,Hibernate抱怨:
Use of @OneToMany or @ManyToMany targeting an unmapped class: blubb.Zoo.animals[blubb.Animal]
我知道<代码>targetEntity-property of @OneToMany
,但这意味着只有Dogs OR 煤炭可以生活在我的动物群中。
是否有办法与解放国一道继续收集一个接口,该接口有几个实施?