Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Serialization

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone say why do we need to go for serialization for persistent storage when we have database
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume by serialization you are refering to serializing objects to the file system. Databases are a better persistent store because:
  • they are transactional
  • they support multiple users
  • they are accessable to other applications, not just Java
  • they can ensure data integrity via constraints
  • they are accessable from environments that can't access the file system, such as an EJB container
  • your 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.
     
    jeff rusty
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 10336
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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?
     
    author and cow tipper
    Posts: 5006
    1
    Hibernate Spring Tomcat Server
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    jeff rusty
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I am not clear. please explain in detail
     
    Ranch Hand
    Posts: 425
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This link will help on why serialize?
    http://en.wikipedia.org/wiki/Serialization
     
    Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic