[semi-OT] java objects persistence and XML id/idref

Discussion in 'Java' started by rico, Oct 27, 2003.

  1. rico

    rico Guest

    Hello All.
    I need some pointers as to how I go about XML'izing a java object
    and referencing it later on if it is encountered in another object in the
    XML'ization process.
    I believe I have to use id & idref... I am thinking the object would
    have to be 'marked' in some way that it has already been serialized
    and what's the corresponding id...
    Some pointers on this topic would be greatly appreciated.
    Thanks.

    Rico.
    rico, Oct 27, 2003
    #1
    1. Advertising

  2. rico wrote:
    > I need some pointers as to how I go about XML'izing a java object
    > and referencing it later on if it is encountered in another object in the
    > XML'ization process.
    > I believe I have to use id & idref... I am thinking the object would
    > have to be 'marked' in some way that it has already been serialized
    > and what's the corresponding id...
    > Some pointers on this topic would be greatly appreciated.


    How about a map from objects to IDs? That seems pretty straightforward.
    If the map doesn't contain a mapping for a particular object then it
    hasn't been serialized yet; if it does then you have the appropriate
    value for an IDREF. The only hitch is generating appropriate unique
    IDs in the first place, but that is certainly doable. You could use the
    objects' hashCodes in such a scheme, but beware that hashCodes are not
    unique.


    John Bollinger
    John C. Bollinger, Oct 27, 2003
    #2
    1. Advertising

  3. rico

    Rico Guest

    "John C. Bollinger" wrote
    > rico wrote:
    >> I need some pointers as to how I go about XML'izing a java object
    >> and referencing it later on if it is encountered in another object in
    >> the XML'ization process.

    >
    > How about a map from objects to IDs? That seems pretty straightforward.
    > If the map doesn't contain a mapping for a particular object then it
    > hasn't been serialized yet; if it does then you have the appropriate
    > value for an IDREF. The only hitch is generating appropriate unique
    > IDs in the first place, but that is certainly doable. You could use
    > the objects' hashCodes in such a scheme, but beware that hashCodes are
    > not unique.


    Thanks a lot John. Looks straightforward indeed.

    Rico.
    Rico, Oct 28, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. javaguy44
    Replies:
    10
    Views:
    974
    Michael Berg
    May 18, 2004
  2. Elhanan
    Replies:
    0
    Views:
    375
    Elhanan
    Aug 22, 2006
  3. jacquesh
    Replies:
    2
    Views:
    561
    jacquesh
    Nov 8, 2006
  4. James Stroud

    py2app semi-standalone semi-works

    James Stroud, Oct 4, 2006, in forum: Python
    Replies:
    2
    Views:
    703
    James Stroud
    Oct 4, 2006
  5. Kenneth P. Turvey

    Java Persistence API and persistence.xml

    Kenneth P. Turvey, Mar 15, 2008, in forum: Java
    Replies:
    2
    Views:
    17,309
    Kenneth P. Turvey
    Mar 16, 2008
Loading...

Share This Page