performance - Dynamic-update with JPA -
i surprised learn default hibernate behavior update of fields in object if single change made , merge called.
dynamic-update field allows configure alternative approach of updating changed field...
http://www.mkyong.com/hibernate/hibernate-dynamic-update-attribute-example/
i using jpa hibernate , tried add following
@javax.persistence.entity @org.hibernate.annotations.entity(dynamicinsert=true, dynamicupdate=true)
to class (previously had jpa annotation)
anyway, i've been monitoring sql , unfortunately didn't change , i'm still seeing every field updated.
this java updates object...
@transactional(readonly = false, propagation = propagation.requires_new) public void setaccountstatusforuser(string username, accountstatus act){ user u = this.getuser(username); u.setaccountstatus(act); this.update(u); }
and update method following:
@transactional(readonly = false, propagation = propagation.requires_new) public object update(object o) { object = this.entitymanager.merge(o); this.entitymanager.flush(); return a; }
any appreciated.
some questions :
- how
getuser()
method work ? - don't use detached objects ?
- is associated record loaded database ?
detached objects not linked original version, origin of word detached. helps hibernate doing comparison, forces full upgrade.
as saw on springsource forum, works when option select-before-update
set true
seems quite logical hibernate has changed. select-before-update
option forces have read original.
if application reads user
database , not working detached objects can't more ideas...
Comments
Post a Comment