| Author |
Serialization
|
jeff rusty
Ranch Hand
Joined: Nov 07, 2006
Posts: 109
|
|
|
can anyone say why do we need to go for serialization for persistent storage when we have database
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
I assume by serialization you are refering to serializing objects to the file system. Databases are a better persistent store because: they are transactionalthey support multiple usersthey are accessable to other applications, not just Javathey can ensure data integrity via constraintsthey are accessable from environments that can't access the file system, such as an EJB containeryour data is not going to become invalid when you update the class you serialized from (unless you are specifying a serialVersionId) and there are probably other reasons.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
jeff rusty
Ranch Hand
Joined: Nov 07, 2006
Posts: 109
|
|
ya i got that .. but i want to know why sould we use Serialized objects (Implements serializable)when we have database thanks in advance Prem
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
If we are still only talking about serialization as it pertains to persisting an object on the file system (and not serialization in the context of distributed programming, i.e. when we need it to send objects between JVMs), I suppose when the overhead of a database is too much for the requirements of a particular application. If, for example, the application is a simple, single user desktop application why would we need the overhead of a database?
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
Serializable - the breakfast interface. Making sure we can pour milk over our JavaBeans and have them for breakfast. Serialization is used not only to store object state to a filesystem, but also to send object state across a network. That's one of the reasons networking in Java is just as easy as interacting with a file system. So, in a clustered environment, you may read a user object in from a database, but the clustered JVM might have to do workload management on the user object - maybe make it available to sessions running on different JVMs. If the object is serializable, then the JVM will be able to pass that Java object around like yesterdays newspaper. If it's not serializable, there will be problems. That's just one, sorta hidden reason, on why it's important to make sure all JavaBeans are serializable.
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
jeff rusty
Ranch Hand
Joined: Nov 07, 2006
Posts: 109
|
|
|
I am not clear. please explain in detail
|
 |
Purushoth Thambu
Ranch Hand
Joined: May 24, 2003
Posts: 425
|
|
This link will help on why serialize? http://en.wikipedia.org/wiki/Serialization
|
 |
 |
|
|
subject: Serialization
|
|
|