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.  [ 3 posts ] 
Author Message
 Post subject: Single Instance in Memory
PostPosted: Fri Aug 18, 2006 12:19 am 
Newbie

Joined: Sat Nov 05, 2005 1:51 pm
Posts: 3
Hi Guys,

I am dealing with a simple concept that I am not able to resolve. I have three classes that I persist using Nhibernate.
1) Doctor (ID, Name)
2) Patient (ID, Name)
3) Appointment (ID, DoctorID, PatientID)

In my appointment class I map two properties Doctor and Patient and setup the many to one relation respectively.

Now when I load the list of appointment, it will have multiple instances for the same patient. So for example:

Appointment # 1, Patient #1
Appointment # 2, Patient #1 (Different Instance)

The reason I know Patient #1 has another instance is because if I change the first instance, the second instance does not change.

In terms of ADO DataSet, this scenario would not have accorded since there would only be a single Patient Row and two Appointment Rows.

Thus, what I am trying to get to is this. Is there a way to have a single instance of Patient loaded for different Appointment object.


Thanks.


Top
 Profile  
 
 Post subject: Re: Single Instance in Memory
PostPosted: Fri Aug 18, 2006 2:08 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
miku wrote:
Now when I load the list of appointment, it will have multiple instances for the same patient. So for example:

Appointment # 1, Patient #1
Appointment # 2, Patient #1 (Different Instance)


If both appointmets are retrived from one session, the patient #1 should be one instance. If from different sessions, The I do not know how to force them to be one inctence... Maybe using session.Lock or something would help...

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject: Re: Single Instance in Memory
PostPosted: Fri Aug 18, 2006 10:10 am 
Beginner
Beginner

Joined: Wed Dec 28, 2005 3:14 pm
Posts: 29
gert wrote:
miku wrote:
Now when I load the list of appointment, it will have multiple instances for the same patient. So for example:

Appointment # 1, Patient #1
Appointment # 2, Patient #1 (Different Instance)


If both appointmets are retrived from one session, the patient #1 should be one instance. If from different sessions, The I do not know how to force them to be one inctence... Maybe using session.Lock or something would help...

Gert


If from different sessions, in the second session, call session.Lock(patien1) or session.Lock(appointment1) before you load appointment2


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

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.