Код: Выделить всё
@Entity
@Table
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Container {
@Id
private Long id;
}
@Entity
@Table
@PrimaryKeyJoinColumn(name = "id")
public class Component extends Container {
@ManyToOne
@JoinColumn(name = "id_parent_container")
private Container parentContainer;
@OneToMany(mappedBy = "parentContainer")
private Set content = new HashSet();
}
@Entity
@Table
@PrimaryKeyJoinColumn(name = "id")
public class Section extends Container {
@ManyToOne
@JoinColumn(name = "id_parent_section")
private Section parentContainer;
@OneToMany(mappedBy = "parentContainer")
private Set children = new HashSet();
}
Когда я запускаю этот код, у меня возникает следующее исключение:
Код: Выделить всё
org.hibernate.AnnotationException: Collection 'xxx.entities.Section.children' is 'mappedBy' a property named 'parentContainer' which does not exist in the target entity 'xxx.entities.Container'
Подробнее здесь: https://stackoverflow.com/questions/792 ... ract-class
Мобильная версия