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.  [ 7 posts ] 
Author Message
 Post subject: nHibernate concurrency approach for mulitple applicn access
PostPosted: Mon Nov 06, 2006 4:39 am 
Regular
Regular

Joined: Thu Aug 24, 2006 2:05 am
Posts: 80
Does nHibernate concurrency approach supports for mulitple aplicatin accessing same database?
Example: Say there are two applications accessing same database. Application 1 and 2 reads the same data. Application 1 does some modification on it and invokde ISession.Update() so that same changes will be reflected into the database. Now application 2 contains stale data, application 2 performs modificaition and tried to update the same using ISession.Update() but update should fail because the data contained by Applicaiton 2 is stale.
Now please let me know whethere nHibernate supported optimistic concurrency mechanism works only if there is single application accessing the database or not?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 6:57 am 
Beginner
Beginner

Joined: Sat Sep 09, 2006 5:55 am
Posts: 23
http://www.hibernate.org/hib_docs/nhibe ... optimistic

_________________
Cheers,

Guy Mahieu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 9:27 am 
Regular
Regular

Joined: Thu Aug 24, 2006 2:05 am
Posts: 80
I have gone through the document but still I am not able to figure out how to use concurrency in multiple ISession?
Is there any setting needs to be done in mapping file?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 12:33 pm 
Beginner
Beginner

Joined: Fri Oct 20, 2006 8:02 am
Posts: 36
Hi.

I'm not sure, but i think the only way to do that is implementing the "Equals" method using all your attributes to compare. Try that. If i'm not wrong the nhibernate uses the "Equals" to compare them before saving it.

Try it and say if it works.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 12:47 pm 
Regular
Regular

Joined: Thu Aug 24, 2006 2:05 am
Posts: 80
My problem is "If there are 2 applications accessing same data,
-Say app 1 and 2 accessed same object i.e. Obj_A
-App1 does some modification on it and calls ISession.Update
-Then App2 does some modification on it and calls ISession.Update on it, now nHibernate should throw an exception as it is a dirty object but it doesn't work in my case.

Thanks,
Deepak


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 2:40 am 
Regular
Regular

Joined: Thu Aug 24, 2006 2:05 am
Posts: 80
Am I missing something in mapping file?
nHibernate optimistic approach for "Many sessions with automatic versioning" is not working for me even though for each data request applicaiotn is creating new ISession object :(


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MisysHealthCare.BusinessEntities.Patient,MisysHealthCare.BusinessEntities" table="Patient" lazy="true" optimistic-lock="all" dynamic-update="true">

<id name="Id" column="ID" type="Int32" unsaved-value="0">
<generator class="identity"/>
</id>
<bag name="PrescriptionList" cascade="all" inverse="true" lazy="true" >
<key column="PatientID" />
<one-to-many class="MisysHealthCare.BusinessEntities.Prescription,MisysHealthCare.BusinessEntities" />
<!--<loader query-ref="PrescriptionList"/>-->
</bag>
<property column="FirstName" type="String" name="FirstName" length="50" />
<property column="MiddleName" type="String" name="MiddleName" length="50" />
<property column="LastName" type="String" name="LastName" not-null="true" length="50" />
<property column="DOB" type="System.DateTime" name="Dob" />
<property column="Gender" type="MisysHealthCare.BusinessEntities.GenderEnumType,MisysHealthCare.BusinessEntities" name="Gender" not-null="false" length="1" />
<property column="SSN" type="String" name="Ssn" length="11" />
<many-to-one name="PrimaryCarePhysicianid" column="PrimaryCarePhysicianID" class="MisysHealthCare.BusinessEntities.Doctor,MisysHealthCare.BusinessEntities" />
<many-to-one name="HomeAddressid" column="HomeAddressID" class="MisysHealthCare.BusinessEntities.Address,MisysHealthCare.BusinessEntities" />
<property column="HomePhone" type="String" name="HomePhone" length="50" />
<many-to-one name="WorkAddressid" column="WorkAddressID" class="MisysHealthCare.BusinessEntities.Address,MisysHealthCare.BusinessEntities" />
<property column="WorkPhone" type="String" name="WorkPhone" length="50" />
<property column="TimeStamp" type="System.Byte[]" name="TimeStamp" length="50" /><!--update="false" insert="false"/>-->
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 4:38 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Try adding a <version> tag to your mapping. You can find information on it in the documentation.

Cheers,

Symon.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.