JPA @ElementCollection в @EmbeddableJAVA

Программисты JAVA общаются здесь
Anonymous
JPA @ElementCollection в @Embeddable

Сообщение Anonymous »

Код: Выделить всё

@Entity
public class School {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer schoolId;
...
@ElementCollection
@CollectionTable(
name = "grades",
joinColumns = @JoinColumn(name = "schoolId")
)
private Set grades;

}
----------------------------------

@Embeddable
public class Grade {

private int gradeId

@ElementCollection
@CollectionTable(
name = "Class",
joinColumns = @JoinColumn(name = "gradeId")
)
private Set classes;

}

------------------------------------

@Embeddable
public class Class {

private int numOfStudent
private int female;
private int mamle;

}

Я хочу получить таблицы сопоставления. Но получите эту ошибку.

Код: Выделить всё

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Property 'com.School.grades.collection&&element.clases' belongs to an '@Embeddable' class that is contained in an '@ElementCollection' and may not be a '@ElementCollection'

Я не уверен, что приведенный выше код верен. Что я могу сделать, чтобы исправить эту ошибку?
попробуйте использовать @ Secondrytable и @AttributeOverride.
Но... не удалось найти решение.

Подробнее здесь: https://stackoverflow.com/questions/784 ... embeddable

Вернуться в «JAVA»