-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to add object in tables in the following situation?
PostPosted: Thu Jun 20, 2013 5:06 pm 
Newbie

Joined: Thu Jun 20, 2013 4:11 pm
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.