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

ios - Change Storyboard View using Seague -

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -