[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object ewoluation.



On Fri, 3 Mar 2000, Falko Braeutigam wrote:

> On Fri, 03 Mar 2000, Radoslaw Wisniewski wrote:
> > I've made a Class named Person with one property "name".
> > I've made one instance and I've set value of property "name" to "Radek
> > Wisniewski".
> > 
> > I've added new property to class Person - "age", and new mathod "setAge"
> > and new method "age" for viewing value of age and I'v updated method
> > toString.
> > 
> > Now I've restartded server and I've invoked new method "age" (getting age)
> > for my old, previously created object Person.
> > I've got an error:
> > 
> > warning: ObjectState: proxy(): unable to create proper proxy object.
> > warning: Transaction: ta(-73) aborting... (java.io.IOException:
> > java.io.InvalidClassException: OsobaImpl; Local class not compatible:
> > stream classdesc serialVersionUID=-9118830836401245661 local class
> > serialVersionUID=2483986366787418531)
> > 
> > It mean that I can't use my old objects :((( if I change Class definition. 
> > Why Ozone doesn't automatycaly update old Instances of the same Class if
> > it is changed?
> > It is inpossible or not implemented yet? 
> > Does another ODBMS make such things?
> 
> There are several ways to solve this problem. The quick solution is to set
> 'serialVersionUID' in your class (see Serialization doc for detail). This will
> allow you to add new methods and members to the classes and initialize them
> with old data that is stored in the database.

Thanks, It's working, but for correct handling values of new fields I have
to owerride readObject( InputSteram str), this method should e.g. copy
default values of new fields if they aren't present in input stream.
Otehrwise I'm getting false data uotput e.g. "age null years". 

Greetings,

Radek Wisniewski

   /--------------A S I----------------/
  / Academical Society of Informatics /
 / Wroclaw University of Technology  /
/____________Poland_________________/