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: Criteria Projections.rowCount() causes update of objects
PostPosted: Fri Feb 22, 2008 1:52 pm 
Newbie

Joined: Tue May 11, 2004 11:27 am
Posts: 1
When testing a DAO while having Hibernate (3) output its SQL, I noticed some unexpected updates.

The test involved a criteria query to fetch a few objects with MaxResults set to 15, then a second criteria query (with the same search criteria) using Projects.rowCount() to get the count of all matching records.

The test simply logs a few of the properties of the objects. No updates are performed.

The problem is that the SQL output shows that the objects retrieved are being updated.

The interesting thing is that if I turn off the second query (the row count query), these updates do not happen.

Does anyone have an explanation for these unnecessary updates when a row count is fetched? Is there a way to work around it?

Thanks in advance
Bryan

The DB is MS SQL, I'm using jTDS as the JDBC driver. The hibernate mapping includes a <version ...> This is a JUnit test in the Spring framework.

As I said, no changes are a made to the objects in this simple test.

In this particular test, the MaxResults happened to be bigger than the number of rows.


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.