-->
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.  [ 2 posts ] 
Author Message
 Post subject: criteria.list() causes session to be dirtied
PostPosted: Tue May 13, 2008 11:55 pm 
Newbie

Joined: Wed Sep 12, 2007 3:13 pm
Posts: 4
Hibernate version: 3.2.6.ga

I have a Criteria query with the following code:
...
Logger.info(this, " dirty session? " + this.getSession().isDirty());
List<BasePersistent> objs = criteria.list();
Logger.info(this, " dirty session? " + this.getSession().isDirty());
...

The output for this piece of code is:
false
true

So criteria.list() is causing my object to be dirtied and when the session is committed the object's version is incremented. I am pretty sure that querying for an object should not be considered to be a modification to the objects in the result set. Any ideas?

Thanks,

Update:
Doh! equals/hashcode weren't implemented properly


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 4:30 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
executing query may result in flushing session -> so all dirty objects will be persist/update to db


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