I have two application servers and 2 database servers named Xapp Xdbase - Yapp Ydabse. Using hibernate at Xapp and Yapp. I need to synchronize data over webservice. With a simple object graph
@Entity
@Table(name="A_table")
public class A 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 and setter for user and bList */
}
public enum B {
One,Two,Three
}
PersistentObject is Serializable and has boilerplate code.
XApp and YApp has these classes.
I create a new A object (lets name it Ainstance) at XApp with a B list including two B objects. Desrialize A and send it to Yapp using a webservice at Yapp. At Yapp, I deserialize incoming A and using a repository, repo.saveOrUpdate(Ainstance); and everything is fine . B_table in Ydbase has 2 records.
Then using old Ainstance at XApp, I add a new B to the list and change the user. Then send A again. It deserializes at Yapp perfectly with 3 B records in bList. But when repo.saveOrUpdate(Ainstance) is called, user change applies to dbase but B_table has 2 records. No errors, nothing.
I tried merging Ainstance @YApp then update without luck. What is the problem with lists? I tried a list with class types and they didn't persist too. What is the mistake?