|
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.
|