I new to spring hibernate. I create one table having columns and their entity should like this
School.java
@Entity
@Table(name = "school")
public class School implements Comparable<School>{
@Transient
private int functionValue;
@Id
@GeneratedValue
private Integer id;
@Size(min = 3, message = "Name must be at least 3 characters!")
@UniqueUsername(message = "School Name already exists!")
@Column(length = 1000, unique = true)
private String name;
private SchoolTier schoolTier1 = new SchoolTier();
private SchoolTier schoolTier2 = new SchoolTier();
private SchoolTier schoolTier3 = new SchoolTier();
//their getter/setter
}
SchoolTier
@Entity
@Table(name = "schooltier")
public class SchoolTier {
@Id
@GeneratedValue
private Integer id;
@Id
private Integer schoolId;
// Pojo's
@Size(min = 0, message = " must be at least 4 characters!")
private String CampusImprovement;
//getter/setter
}
Having a table by the name of school which having same column which define in school.java and also having the table schooltier which have same column as defined in schooltier.java
But problem is here like school table doesn't having any columns for 'SchoolTier' but in school.java I have 3 object of schooltier. Now it gives an exception like
Caused by: org.hibernate.MappingException: Could not determine type for com.scp.bid.entity.SchoolTier at table: school, for columns: [org.hibernate.mapping.Column(schoolTier1)]
Now how to resolve this issue ? Please guide me if I did something wrong. Help me
@OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="SCHOOL_TIER_ID") private SchoolTier schoolTier1@Idon theschoolIdinSchoolTier.