Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

How do I store my objects?  XML/binary/schema

Thread view: 
timasmith@hotmail.com - 24 Feb 2006 21:54 GMT
Hi,

I noticed with .Net the framework provides a simple ability to
serialize an object to XML and back again.

Does Java have the same functionality?

Also, I have a system which needs to persist objects and then perform
some custom scripting on them - I assume storing objects as binary
would be ill advised due to version incompatibility - but XML would be
make need for a *huge* table - although I guess I could zip and store
them.  That might be slow and a lot of overhead to extract them though.

Store binary or XML or zipped XML or as columns on tables?

thanks

Tim
James McGill - 24 Feb 2006 22:29 GMT
> Hi,
>
> I noticed with .Net the framework provides a simple ability to
> serialize an object to XML and back again.
>
> Does Java have the same functionality?

Java has a standard API for extensions that do XML binding, and there's
a Sun reference implementation.  

http://java.sun.com/webservices/jaxb/index.jsp

I use Castor for this, though not a standard JAXB implementation, and I
find it to be excellent and pretty efficient.  Many of my applications
are built starting with an XML Schema and I use Castor to automatically
generate objects from that.  Starting there, it's extremely easy to
Marshall/Unmarshall objects to and from XML, and I also do database
binding to the same objects.

The problem with having a "simple" ability to marshal or unmarshal, is
that the relationship between an object and its XML representation is
not always quite so simple.

If you don't really care about the structure of the XML and don't need
precise control over naming and type conversion, you can use XStream
very simply.

> Also, I have a system which needs to persist objects and then perform
> some custom scripting on them - I assume storing objects as binary
> would be ill advised due to version incompatibility - but XML would be
> make need for a *huge* table - although I guess I could zip and store
> them.  That might be slow and a lot of overhead to extract them though.

I use Hibernate to map my objects (the same ones I map to XML Schema) to
a database.  It's pretty efficient both in terms of storage size and
performance, but that's relative, of course.  Since I specialize in a
certain type business software, I consider the benefits to data
integrity and the design-by-contract opportunities that come with xml
binding, to far outweigh performance considerations.  
Thomas Fritsch - 25 Feb 2006 01:09 GMT
> I noticed with .Net the framework provides a simple ability to
> serialize an object to XML and back again.
>
> Does Java have the same functionality?

See the classes
   java.beans.XMLEncoder,
   java.beans.XMLDecoder

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

timasmith@hotmail.com - 25 Feb 2006 02:25 GMT
I did - so neither this nor Castor seems to do a deep copy of my
objects - is that a flag on either?
I have a hierarchy of objects which all need to be stored.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.