I have a bunch of complex java objects stored in a blob column in a database - so far so simple
Lets say these objects contain a primitive long member that holds an numeric ID of some kind, but this ID now needs to change from a long to a String holding some kind of guid (the actual scenario is a *LOT* more complicated than that, this is just by way of an example)
What I need to be able to do is to get all the "old style" objects out of the database, change that field from a long to a String with an updated value and write it back as a "new style" object.
e.g. (heavily simplified) the existing objects in the database are like
class Rank {
long ownerID;
String rank;
}
and need to be replaced with a new version of the same class
class Rank {
String ownerID;
String rank;
}
for now quite happy for the ownerID to be just a string version of the long id as thats an easy fix for later, the problem is how to change the fields type.
An added complication is that it needs to be run at clients sites, so needs to be as simple as possible for the poor dears - Ideally a single program with a big button saying "update"
I have been playing around with this for over a week now, and tried all kinds of horrible concoctions, I now feel I know ObjectInputStream.readObject() inside out, but there doesnt seem to be a simple way to do what I want, especially when its a primitive I want to change. You can replace objects by overloading the resolveObject method, but obviously im replacing one class with itself, but different in a quantum way - have tried messing with separate classloaders to hold old and new versions of the objects and try to copy fields from one to the other - but that didnt go far as the actual objects are huge.
Has anyone been faced with a similar problem before, and if so please tell me you found a miracle cure that youre willing to share
cheers
<< JOC >>
Lets say these objects contain a primitive long member that holds an numeric ID of some kind, but this ID now needs to change from a long to a String holding some kind of guid (the actual scenario is a *LOT* more complicated than that, this is just by way of an example)
What I need to be able to do is to get all the "old style" objects out of the database, change that field from a long to a String with an updated value and write it back as a "new style" object.
e.g. (heavily simplified) the existing objects in the database are like
class Rank {
long ownerID;
String rank;
}
and need to be replaced with a new version of the same class
class Rank {
String ownerID;
String rank;
}
for now quite happy for the ownerID to be just a string version of the long id as thats an easy fix for later, the problem is how to change the fields type.
An added complication is that it needs to be run at clients sites, so needs to be as simple as possible for the poor dears - Ideally a single program with a big button saying "update"
I have been playing around with this for over a week now, and tried all kinds of horrible concoctions, I now feel I know ObjectInputStream.readObject() inside out, but there doesnt seem to be a simple way to do what I want, especially when its a primitive I want to change. You can replace objects by overloading the resolveObject method, but obviously im replacing one class with itself, but different in a quantum way - have tried messing with separate classloaders to hold old and new versions of the objects and try to copy fields from one to the other - but that didnt go far as the actual objects are huge.
Has anyone been faced with a similar problem before, and if so please tell me you found a miracle cure that youre willing to share
cheers
<< JOC >>