This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Serial version ID for the serialized objects in DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Serial version ID for the serialized objects in DB" Watch "Serial version ID for the serialized objects in DB" New topic
Author

Serial version ID for the serialized objects in DB

rakesh cp
Greenhorn

Joined: Feb 11, 2014
Posts: 2
Hi,

I have few serialized objects in a table in SQL server whose data type is Image. Could some one let me know how to know the serial version ID of this? We have to verify all these objects in all environments and since we are migrating it to java 1.6, we need to make sure they are consistent across all environments.

Thanks,
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3574
    
  14

Uhhh isn't the serialVersionUID automatically checked when you deserialize the object?
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2982
    
    9
Yes, at first glance it would seem the easiest way to do this is to simply try to deserialize some of these objects using Java 6 and see if it works. If the serialVersionUid is wrong, you will get a clear error message. If there are a lot of these objects and you can't test them all, then at least try testing as many of them as you can, using a random sample.

What sort of Image is this, really? I assume it's not a java.awt.Image, since those are not serializable. In general I'm suspicious of the idea of using serialization for image data - I would recommend using java.awt.ImageIO and its read() and write() methods to do this. But it sounds like you may be stuck with existing data that was written a certain way, OK. If you are using Java serialization, what exact class or classes are the serialized objects from? And, is it a class that has changed implementation at all in JDK 6? Is it a class under your control, or a library class of some sort?
 
 
subject: Serial version ID for the serialized objects in DB
 
Similar Threads
Versioning of classes with respect to serializing objects
How to know the number of items in your Seralization/Deserialization stream?
Generated Serial ID Vs. Default Serial ID in EJB
Serialization - SerialVersionId
Safe to remove fields that are nulls?