-->
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.  [ 4 posts ] 
Author Message
 Post subject: Srange behavior when I try to get an Object from cache
PostPosted: Tue Aug 15, 2006 4:07 pm 
Newbie

Joined: Tue Aug 15, 2006 3:14 pm
Posts: 1
First of all, I´m sorry about my English.
I found a strange behavior when I try to get an Object that has being changed in cache.
I try to get it using ICriteria.

These are the steps in order to reproduce it:

1) Begin a Transaction
2) Create a new Object that has 1 as a value for a bit Property
3) Save Object (without commit the transaction)
4) Get same Object (using Get Method) and update its bit Property to 0
5) Save again the Object without commit the transaction
6) When I try to get objects that has 1 as value in the bit Property thru ICriteria, NHibernate retrieve the previous Object however its value is 0.
All properties in the returned object are correct, but It seems that NHibernate apply incorrect filter.


If I Commit transaction and retry the point number 6, I get the correct Object.


Top
 Profile  
 
 Post subject: Re: Srange behavior when I try to get an Object from cache
PostPosted: Sat Sep 29, 2007 9:57 am 
Beginner
Beginner

Joined: Fri Jul 29, 2005 10:34 am
Posts: 25
asztern wrote:
First of all, I´m sorry about my English.
I found a strange behavior when I try to get an Object that has being changed in cache.
I try to get it using ICriteria.
.


I think your problem is related with my post:
http://forum.hibernate.org/viewtopic.ph ... 95#2365895

In a nutshell, i think that if you use ICriteria, the session cache is not used. I will do more tests so keep watching that other post for more news. ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 30, 2007 1:13 pm 
Beginner
Beginner

Joined: Mon Jul 30, 2007 4:58 pm
Posts: 21
you can try flushing the session and refreshing the object as well


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 30, 2007 1:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
In step 5, when you "save again", I assume you meant you called Update()? First observation: The object that you save in step 3 and step 5 are the same object. When you retrieve the object you saved in step 3, you have updated its bit property to 0 in step 5. Very basic property of a transaction is that it is consistent with itself. Since you updated the bit property to 0 in step 5, the object you got back in step 6 would of course have 0 in its bit property. The fact that you have not committed the transaction in step 5 is irrelevant because everything was carried out in the same transaction.

Extra note: I can't recall what would happen if you call Save() on the same object twice in the same session. I don't recall whether it would update the object on the second call, or insert another one. At any rate, it is not "typical usage" (I don't think) to call Save() on the same object twice in the same ISession.

_________________
Karl Chu


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