java - Temporarily disable Hibernate entity version checking -


i have page display contacts. read page , iterate through contacts group , display them:

//not lazy load of contacts, cannot use lazy loading list<contact> contacts = someservice.getcontacts(groupid);  (contact contact : contacts) {     //add contact properties model displayed later } 

at same time might have separate, background thread updates 1 of contacts. thread updates field i'm not going display, i'm ok data desynchronising in case.

the problem hibernate update contact's version number , commit db (when background thread finishes). when loop hits such object following exception thrown.

org.hibernate.staleobjectstateexception: row updated or deleted transaction (or unsaved-value mapping incorrect) 

which ok. there way disable object's version checking during iteration through hibernate's collection? when disable, mean in particular scenario, in particular loop? not other situations.

i think happens because underlying collection abstractpersistentcollection , iterator check each member's version corresponding db value.

if doing read-only operation, should not staleobjectstateexception. exception thrown when doing update data stale , hibernate detects using version information.

so check code , make sure not doing unneeded updates read-only operation of displaying contacts.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -