I am using HIbernate3.2.0cr2 with hibernate-anntations-3.2.0
I have the foll . use case :
Student ------ Registrar ---------College
I am using annotations for specifying many-to-many relationship via the association table "Registrar"
Here are the POJOs :
Student.java :
@Entity
@Table(name = "tbl_student")
@Inheritance(strategy=InheritanceType.JOINED)
public class Student implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
protected Set colleges = new HashSet();
public Student() {
}
@Column(name = "student_name", nullable = false, length = 50)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long student_id) {
this.id = student_id;
}
@ManyToMany(
cascade={CascadeType.PERSIST, CascadeType.MERGE},
mappedBy="college",
targetEntity=College.class
)
public Set getColleges() {
return colleges;
}
}
College.java :
@Entity
@Table(name = "tbl_college")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "college_type",
discriminatorType = DiscriminatorType.STRING)
public class College implements Serializable {
@ManyToMany(
targetEntity = Student.class,
cascade = { CascadeType.PERSIST,CascadeType.MERGE }
)
@JoinTable(
name = "TBL_REGISTRAR",
joinColumns = { @JoinColumn(name = "COLLEGE_ID") },
inverseJoinColumns = { @JoinColumn(name = "STUDENT_ID") }
)
public Set getStudents() {
return students;
}
protected Set students = new HashSet();
private static final long serialVersionUID = 1L;
Long college_id;
private String name;
public College() {
// TODO Auto-generated constructor stub
}
@Column(name = "college_name", nullable = false, length = 50)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getCollege_id() {
return college_id;
}
public void setCollege_id(Long college_id) {
this.college_id = college_id;
}
}
Registrar.java:
@Entity
@Table(name = "tbl_registrar")
public class Registrar implements Serializable {
private static final long serialVersionUID = 1L;
public Registrar() {
}
}
I am getting this exception :
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown property: com.webify.registration.domain.College.college in com.webify.registration.domain.Student.college
Pls help me with the mapping?
|