i have hibernate app trying implement open session in view pattern
zk have question hibernate creates session per thread , closes have severals operations [criteria , save or update] methods in 1 session started implement using update method received infamous
nonuniqueobjectexception
we have changed update()
merge()
question if following.
if have student
class , trying update the student using update[making sure not in session avoid exception]
later in other method student required updated again differently previous update
time should merging
, merge()
method called. wondering when [flush][commit]
method called changes first student loss? changes both students ok? happens??
i afraid changes in first student
loss! can in case?
thanks lot best regards.
you should take @ locking algorithm. there 2 popular ones: optimistic , pessimistic. web application optimistic locking works better. long story short each revision of entity object given version label (often bigint or string db column). when pre-empt update , version became stale, hibernate throw optimistic lock exception, in case can capture , ask user (or take other appropriate measure)
Comments
Post a Comment