Hello,
I have 2 different objects dbobj and xmlobj, both are objects of
same Class and dbobj.equals(xmlobj) is false.
dbobj is read from database with hibernate.
xmlobj is an object created from an xml file.
Now i have to Sync dbobj in such a way that, dbobj gets updated
with all the new values present in xmlobj (excepting primary key).
It works fine if i update the primary key on xmlobj (taken from the
dbobj's primary key) and save xmlobj. I have understood that if the
Class has reference to Children then all those child objects' primary
keys needs to be updated from dbobj to xmlobj, otherwise new rows
will be created for those children and earlier children objects will loose
their reference.
I have come up with a class, which recurses the dbobj and collects
all the children's primary keys and updates the xmlobj accordingly
and it works fine now. However, if i have a child of type List/Collection
my code fails for those children.
I cant think of any other solution for achieving the same for collection
based Objects(children) and feel all the roads are blocked for me. This
is the heart of the project i work on and i find no other way.
Kindly, advice me if there is any other/better way to do it or any
simple way in hibernate which already does this.
Thank you all of you people who are involved in development,
administration, support and all whoever involved actively or passively,
for such a great great project. Thanks a lot!!
Thanks in advance,
Regards,
Sanjeev
|