java - Exception because of stale OneToMany relation when merging -


my entities like:

class parent {    @id    long id;     @onetomany(fetch=fetchtype.eager)    @joincolumn(name="childid", insertable=false, updatable=false)    set<child> children = new hashset<child>(); }  class child {    @id    long id; } 

i have parent entity child loaded in thread a. in thread b, code deletes child belongs parent entity in thread a. result, thread encounter javax.persistence.entitynotfoundexception when calling entitymanager.merge() because field children contains stale data has been deleted.

how should handle concurrent situation?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -