Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [semi-OT] java objects persistence and XML id/idref

Reply
Thread Tools

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

 
 
rico
Guest
Posts: n/a
 
      10-27-2003
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.


 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      10-27-2003
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
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
Rico
Guest
Posts: n/a
 
      10-28-2003
"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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Persistence API and persistence.xml Kenneth P. Turvey Java 2 03-16-2008 12:08 AM
Probstat Combination Objects and Persistence dohertywa Python 2 09-17-2007 08:07 PM
Database objects? Persistence? Sql Server woes Mike Howarth Python 1 07-30-2007 05:35 PM
Java Object Persistence (JSP & Java) Snyke Java 4 11-02-2005 10:57 PM
EJB persistence versus Database persistence? javaguy44 Java 10 05-18-2004 07:08 PM



Advertisments