Is there a way to disable it? I would like to minimize Hibernate sql if possible. The object that I get from the database should be 'clean' instead of 'dirty' so hibernate shouldn't need to update it. Right?
First the code is tough to read. There is a CODE button below Add Reply button to put CODE tags in your post so that you can put your actual code in between them and keep its indentation.
But I am thinking that there must be more to your code that you didn't post.
If you had loaded an object, made a change, then run a query, Hibernate will execute the update for the changed object when the query is run because in order for Hibernate to be sure that th query will return the correct results it needs to update/insert/delete data that might be changed that needs to be changed in the database so that the query gets the correct data.
>> Why are you committing the transaction after the call to list()? This is because I just get the presistent object thru the query. And I return from the getCat() method , as a result, I commit the transaction before I return the 'Cat'.
>> Which line appears to be triggering the update sql to execute. (Is it happening during the commit?)
Yes, it happens during commit.
>> What was the value of version in the database before the select? Was it null? It was 0
>> Set the Hibernate log level to DEBUG. You should see some log entries that specify which property of cat is dirty. (Search for "dirty".)