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 / May 2006

Tip: Looking for answers? Try searching our database.

Serializing an ArrayList to disk

Thread view: 
Ike - 18 May 2006 20:28 GMT
If I serialize an ArrayList to disk, soes it also serialize the objects in
the ArrayList? And if so, why would I opt for using, say, Hibernate, to
persist an ArrayList, as opposed to just Serializing it ? Thanks, Ike
Matt Humphrey - 18 May 2006 22:04 GMT
> If I serialize an ArrayList to disk, soes it also serialize the objects in
> the ArrayList? And if so, why would I opt for using, say, Hibernate, to
> persist an ArrayList, as opposed to just Serializing it ? Thanks, Ike

Serializing an ArrayList (or HashMap, etc) serializes everything reachable
from that starting point (not counting transients and objects already
serialized.)  The resulting encoding (binary, XML, whatever) can easily be
stored and retrieved, but is difficult to work with--search, query, modify.
To do anything meaningful with it usually means you have to totally
deserialize it.

If all your system needs to do is to store and retrieve opaque objects,
that's ok--I've built a number of systems like that.  However, Hibernate
(and other persistence tools) store object to a relational database in way
that makes the object structure visible and accessible to other relational
operations.  You can search and manipulate the data as tables and then
reconsitute the revised objects.  Just being able to perform relational
queries over the objects makes this technique worthwhile.

Cheers,
Matt Humphrey  matth@ivizNOSPAM.com http://www.iviz.com/
VisionSet - 18 May 2006 22:23 GMT
> If I serialize an ArrayList to disk, soes it also serialize the objects in
> the ArrayList? And if so, why would I opt for using, say, Hibernate, to
> persist an ArrayList, as opposed to just Serializing it ? Thanks, Ike

You should not use serialisation for anything other than short term, eg
streams.  The risk is you lock your development to the time of that 1st
serialisation.  There are ways to ease this, like declaring your own
serialUID and being aware of what you can change.  But none are really
satisfactory since you don't have a crystal ball.  Use Hibernate and/or
databases, and store more granular entities.

--
Mike W
VisionSet - 18 May 2006 23:22 GMT
> > If I serialize an ArrayList to disk, soes it also serialize the objects in
> > the ArrayList? And if so, why would I opt for using, say, Hibernate, to
[quoted text clipped - 6 lines]
> satisfactory since you don't have a crystal ball.  Use Hibernate and/or
> databases, and store more granular entities.

Of course, your usage may well be for short term persistence.

--
Mike W


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



©2008 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.