aspose file tools
The moose likes Java in General and the fly likes object byte array to object instance Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "object byte array to object instance" Watch "object byte array to object instance" New topic
Author

object byte array to object instance

sam bartl
Ranch Hand

Joined: Oct 29, 2010
Posts: 43
We save object instance byte array into database , reload it into object instance . Suppose I have instance byte array in database and we modified object by adding a new property , old properties are as it is, now If I try to reload this byte array into modified object instance I get call cast exception is the any way I can reload the byte array into this modified object ?


William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12268
    
    1
IF what you are talking about is
1. serializing an object instance to a byte[] and saving it.
2. revising the class by adding a new variable (think variable, not property) (not modifying object, modifying class)
3. attempting to recover the serialized object using the new class definition.

THEN
No you can't, why would you expect to be able to?

See java.io.Serializable JavaDocs for the use of serialVersionUID

IF you are not talking about serializing an object, please explain more.

Bill

Java Resources at www.wbrogden.com
sam bartl
Ranch Hand

Joined: Oct 29, 2010
Posts: 43
I am assuming this will work if my object delcares a serialVersionUID




please advice me what value should I give to this variable
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Omit it at first, then use the "serialver" tool that you can find in the JDK's bin folder to generate one for you. If you use an IDE you can also let it generate it for you; it probably uses serialver in the background.
Then just copy and paste this declaration, and make it private.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: object byte array to object instance
 
Similar Threads
How to encrypt Database?
Regarding the Soap Message
byte array to String
How to upload a byte array into BLOB column?
working with the DataBase