Hii,I have three classes
Code:
patient{
int pid; //Primary
string pname;
Set<Alert> Alert a;}
patient is map one to many with alert(using pid)
Code:
Alert{
int aid //primary key auto increment
int pid //foregin key references patient(pid)
int mid //foreign key references message(mid)
string type;
Patient p; //Also consider the case when it is unidirectional
Message m;
}
Alert is map one to one with message (using mid)
Code:
message{
mid //primary key auto increment
text_message
}
Is such a mapping possible?(Mapping rules are followed?)
If no,what changes can make it?(may be exchanging keys)
If yes,
how will i save instances of Alert in patient and message in Alert?
i.e patient.setAlert() and alert.setmessage();
Code:
Patient p=new Patient(123,Atul);
message m=new message(3456,"Hey,Hibernate is great and people developing them are awesome");
Alert a=new alert();
alert.setType("Please help me");
How should I save alert now so that the mapping will hold?Consider both the case when patient to alert is one to many unidirectional or bidirectional?
Code:
a.setMessage(m);
p.addAlert(a)
will work?