Hi all,
I am using struts2 + hibernate for my current project
I have a
student table which has following data
a) serialno <primary key>
b) firstname
c) lastname
I have a
registration table which has following data
a) id <primary key>
b) serialno <this is the serial no from the student table>
c) registrationno
I have a
demanddraft table which has following data
a) id <primary key>
b) serialno <this is the serial no from the student table>
c) demanddraftno
My condition is as follows.
1) Create the student
2) Create a registration for the student based on serial_no
3) Create a demand draft for the student based on serial_no
My problems is as below
1) There is one-to-one mapping between student and registration and also student and demand draft.
How to do this ?
2) What is the best approach for this kind of design ?
Regards,
Vanlal
Code:
@Entity
@Table(name = "student")
public class Student implements Serializable {
private RegistrationInfo regninfo;
public void setRegninfo(RegistrationInfo regninfo) {
this.regninfo = regninfo;
}
@OneToOne
@JoinColumn(name="regninfo_id")
public RegistrationInfo getRegninfo() {
return regninfo;
}
private DDInfo ddinfo;
@OneToOne
@JoinColumn(name="ddinfo_id")
public DDInfo getDdinfo() {
return ddinfo;
}
public void setDdinfo(DDInfo ddinfo) {
this.ddinfo = ddinfo;
}