Hi Alexander,

Thanks for reply. I am using the approach (in a bit different way) you
suggested with the help of post-set method hooks.

First of all, I am not relying on PK as they might be different on target
system. In my postset methods, I am using business keys to fetch the
existing objects. Now after retrieving the object from DB, I get its id
and version and set it on new object.

Reason for doing so are:

1. I am using same approach for updating existing objects. Hence if I
simple change the reference then changes being imported will be lost.

2. Relationships in my case are bit complex like A->B->C->D. Now there
could be a case where this relationship is changed on source system as
A->B->C'->D (where A, B and D are already existing objects). So while
importing I can't simply replace the instance of B being imported with
existing one as I'll lose reference to C'.

3. Moreover even if I replace A's reference to existing instance of B, it
will not be replaced in ummarshalling stack (i think) so later if I'll
access stack I wont get reference to existing object.

thanks
rohit

Hi Rohit,

if I undestood it right, I think you have to add some extra logic to your
importer:

1. After unmarshalling the object which contains the reference (let's call
it object A) access the referenced object (let's call it B) and fetch it's
primary key.

2. Because an object with the same attributes as B (let's call it C) is
already persistent in your system, you can use this PK to fetch it with
Hibernate.

3. Now replace A's reference to B by a reference to the persistent C. B
can be discarded.

4. Make A persistent. Hibernate will recognize that it's connected to C
and that C hasn't changed - so only A will be inserted and it will have a
reference to C.

Alexander

> -----Ursprüngliche Nachricht-----
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Auftrag von
> Rohit Seth
> Gesendet: Mittwoch, 12. Oktober 2005 17:56
> An: [email protected]
> Betreff: [jibx-users] Using JibX with hibernate
>
>
> Hi,
>
> I am trying to use jibx with Hibernate. My goal is to pull
> data out of one
> system (in form of hibernate objects), marshall them to xml
> files using
> jibx and then use these xml files to import data on some other system.
>
> I am able to export data from source system successfully but
> having some
> issue with import.
>
> While importing data, there could be a case where a new
> object has to be
> created which reference to some existing object. While
> marshalling jibx
> pulle out that object in xml file but I don't want that object to be
> created while importing (as that object already exists on
> target system).
>
> I'll appreciate any help in this regard.
>
> thanks
> rohit





-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to