tags:

views:

144

answers:

3

My hibernate versioning is issuing an update statement for no apparent reason.

In my BankAccount mapping file:

<version type="dbtimestamp" name="modified" column="Modified"/>

inthe AvailableBalance mapping file:

<many-to-one name="bankAccount" class="model.businessdomain.orm.BankAccount" fetch="select" >
   <column name="BankAccountId" not-null="true" />
</many-to-one>

The resulting sql statements issued, when a select is done from the AvailableBalance table (via a function):

17:12:16,152 DEBUG SQL:401 - select * from dbo.get_availablebalancelist(?) ab  where ab.bankAccountId = ?
17:12:31,539 DEBUG SQL:401 - select current_timestamp
17:12:31,625 DEBUG SQL:401 - update dbo.BankAccount set Modified=?, BankAccountTypeId=?, BankID=?, InterestSchemeID=?, BankAccNo=?, SysParamID=?, BankAccName=?, BranchCode=?, UserRef=?, CAMSCode=?, Provision=?, ProvisionPerc=?, OverDraftLimit=?, isIslamic=?, Active=? where BankAccountId=? and Modified=?
A: 

Is the object being modified in memory in any way after the select? If the object is marked at dirty, depending on your transaction strategy, a commit may be occurring which could be implicitly updating the database.

Clay
A: 

The reason for that update is most probably not in the code you posted.

To debug it, you could set a break point in your logging facility, and look at the stack that issues this statement.

meriton
A: 

This seems to be a case where your object is modified but you don't want to.

Most probable is a setter of the BankAccount class which breaks the Bean recommendation, I mean it do something else than set the passed value to a local variable.

Killerwhile