@Entity
public class School {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer schoolId;
...
@ElementCollection
@CollectionTable(
name = "grades",
joinColumns = @JoinColumn(name = "schoolId")
)
private Set<Grade> grades;
}
----------------------------------
@Embeddable
public class Grade {
private int gradeId
@ElementCollection
@CollectionTable(
name = "Class",
joinColumns = @JoinColumn(name = "gradeId")
)
private Set<Class> classes;
}
------------------------------------
@Embeddable
public class Class {
private int numOfStudent
private int female;
private int mamle;
}
I want to get mapping tablels. But, get this error.
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'
I’m not sure above code is correct. What can I do to fix this error?
try to use @secondrytable and @AttributeOverride.
But.. couldn’t find solution.
New contributor
Andrew Oh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.