More details, this issue is a blocker for my project, I have to fix it.
If you have information, please share it.
I have written a simple test using programmatic transaction because I was hoping to gain mor control over the behavior when my transaction closes, but the problem reproduces exactly with decalred transactions.
My test creates a read/write context, loads a single object, but doesn't modify it and exits.
Code:
public Boolean testPersist() {
// using programmatic transactions
transactionTemplate.execute(
new TransactionCallback(){
public Object doInTransaction(TransactionStatus ts) {
try{
VersionDomain v = versionDao.getVersion(1);
}catch (Exception e) {
ts.setRollbackOnly();
}
return ts;
}
}
);
return true;
}
My logs show two updates, one for each doamin object loaded: my version, and the product associated with the version in a ManyToOne relation, meaning many versions for each product.
Code:
12:49:46,328 INFO [STDOUT] 2009-08-22 12:49:46,328 DEBUG [org.hibernate.SQL] - select versiondom0_.id as id41_4_, versiondom0_.codename as codename41_4_, versiondom0_.date_created as date3_41_4_, versiondom0_.date_modified as date4_41_4_, versiondom0_.description as descript5_41_4_, versiondom0_.link as link41_4_, versiondom0_.product_id as product10_41_4_, versiondom0_.unified_version_id as unified7_41_4_, versiondom0_.user_id as user11_41_4_, versiondom0_.versionname as versionn8_41_4_, versiondom0_.nostaw_version as nostaw9_41_4_, product1_.id as id25_0_, product1_.date_created as date2_25_0_, product1_.date_modified as date3_25_0_, product1_.deprecated as deprecated25_0_, product1_.description as descript5_25_0_, product1_.latest_version_id as latest6_25_0_, product1_.link as link25_0_, product1_.name as name25_0_, product1_.restricted as restricted25_0_, product1_.sap_code as sap10_25_0_, product1_.type_id as type14_25_0_, product1_.unified_prod_id as unified11_25_0_, product1_.user_id as user15_25_0_, product1_.nostaw_family as nostaw12_25_0_, product1_.nostaw_product as nostaw13_25_0_, producttyp2_.id as id27_1_, producttyp2_.date_created as date2_27_1_, producttyp2_.date_modified as date3_27_1_, producttyp2_.description as descript4_27_1_, producttyp2_.name as name27_1_, userdomain3_.id as id39_2_, userdomain3_.admin as admin39_2_, userdomain3_.obadenet_uid as obadenet3_39_2_, userdomain3_.date_created as date4_39_2_, userdomain3_.date_modified as date5_39_2_, userdomain3_.kitn_id as kitn6_39_2_, userdomain4_.id as id39_3_, userdomain4_.admin as admin39_3_, userdomain4_.obadenet_uid as obadenet3_39_3_, userdomain4_.date_created as date4_39_3_, userdomain4_.date_modified as date5_39_3_, userdomain4_.kitn_id as kitn6_39_3_ from xedoc_admin.tbl_versions versiondom0_ left outer join xedoc_admin.tbl_products product1_ on versiondom0_.product_id=product1_.id left outer join xedoc_admin.tbl_product_types producttyp2_ on product1_.type_id=producttyp2_.id left outer join xedoc_admin.tbl_users userdomain3_ on product1_.user_id=userdomain3_.id left outer join xedoc_admin.tbl_users userdomain4_ on versiondom0_.user_id=userdomain4_.id where versiondom0_.id=?
12:49:46,586 INFO [STDOUT] 2009-08-22 12:49:46,586 DEBUG [org.hibernate.SQL] - update xedoc_admin.tbl_products set sap_code=?, nostaw_family=?, nostaw_product=? where id=?
12:49:46,613 INFO [STDOUT] 2009-08-22 12:49:46,613 DEBUG [org.hibernate.SQL] - update xedoc_admin.tbl_versions set link=?, nostaw_version=? where id=?
What can I do to prevent unecessary updates?
I want to do updates only if the object really was changed. These useless updates are cause deadlocks in the clustered hosting einvirenment.
I was not seeing this behavior while I was using MySql.
Thanks for help.
Looks like bug actually.
Thanks for help. Much appreciated.
jacques
Config: Spring 2.5.6, hibernate-core 3.3.2.GA, hibernate-entitymanager 3.4.0.GA, Oracle JDBC Driver version 10.2.0.3.0, Oracle 10.2.0.3 (10GR2)