java - Unable to persist lists of a graph after deserializing, using hibernate and webservices -


i have 2 application servers , 2 database servers named xapp xdbase - yapp ydabse. using hibernate @ xapp , yapp. need synchronize data on webservice. simple object graph

@entity @table(name="a_table") public class extends persistentobject  {     @column(name="user")     private string user;      @elementcollection()     @enumerated(enumtype.string)     @column(name="b_column")     @collectiontable(name="b_table")     @lazycollection(lazycollectionoption.false)     private list<b> blist= new arralist<b>();       /* here comes getter , setter user , blist */ }  public enum b {     one,two,three } 

persistentobject serializable , has boilerplate code.

xapp , yapp has these classes.

i create new object (lets name ainstance) @ xapp b list including 2 b objects. desrialize , send yapp using webservice @ yapp. @ yapp, deserialize incoming , using repository, repo.saveorupdate(ainstance); , fine . b_table in ydbase has 2 records.

then using old ainstance @ xapp, add new b list , change user. send again. deserializes @ yapp 3 b records in blist. when repo.saveorupdate(ainstance) called, user change applies dbase b_table has 2 records. no errors, nothing.

i tried merging ainstance @yapp update without luck. problem lists? tried list class types , didn't persist too. mistake?

after bit more reading, found answer "replicate".

replicate() intended used instead of save()/persist() when need save entity given identifier despite fact identifier of said entity configured generated.

it's useful when of entities (perhaps coming external systems) have pre-existing identifiers, whereas other entities of same type need identifiers generated.

says axtavt, @hibernate: refresh, evict, replicate , flush


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -