This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializable Interface

 
vidya Sreedharan
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is it possible to persist an object to a database without implementing Serializable marker interface ?

Thanks,
Vidya
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Persist" can be understood to mean many different things. APIs like JPA work with annotations to indicate how objects should be persisted to a DB.

Persisting a serialized binary version of an object is a fraught business that should be avoided. Slightly better (if using something like JPA is not an option) would be to use the java.beans.XMLEncoder/XMLDecoder classes (assuming that the objects follow JavaBean semantics).
 
Sagar Rohankar
Ranch Hand
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf, are you suggesting that plain serialization of object is not good choice and you should look for other option like, XMLEncoder/Decoder ?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. There are valid uses for binary serialization, but storing objects in a DB is not one of them.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic