This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Serializable Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Serializable Interface" Watch "Serializable Interface" New topic
Author

Serializable Interface

vidya Sreedharan
Greenhorn

Joined: Jun 27, 2007
Posts: 4
Hi,

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

Thanks,
Vidya
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
"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).


Ping & DNS - my free Android networking tools app
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Ulf, are you suggesting that plain serialization of object is not good choice and you should look for other option like, XMLEncoder/Decoder ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
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
 
subject: Serializable Interface
 
Similar Threads
Failed to marshal exception problem
Serielizible?
I meet a problem. It is very interesting!!!!!!!!!!!!!!!!
RMI:at client side getting exceptrion like java.io.NotSerializableException
Are collections Serializable Objects