-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentDetails.java
51 lines (40 loc) · 1.26 KB
/
StudentDetails.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.hibernate.dto;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
@Entity
public class StudentDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int studentId;
private String studentName;
/* Indicates hibernate that this is a java collection */
@ElementCollection
@JoinTable(name = "STUDENT_HOBBIES", // customised table name
joinColumns = @JoinColumn(name = "STUDENT_ID")) //customised joining column name
private Collection<HobbyDetails> hobbies = new ArrayList<HobbyDetails>();
public int getStudentId() {
return studentId;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public Collection<HobbyDetails> getHobbies() {
return hobbies;
}
public void setHobbies(Collection<HobbyDetails> hobbies) {
this.hobbies = hobbies;
}
}