hello,
I use hibernate with an in-process HSQLDB in my application to save projects (an instance of Project with about 7 other classes involved) to disk. Obviously the structure of these classes may change.
So when loading a project from hibernate persistence, I need to check the version of each class (instance variable 'version' that is persisted), and load the class matches the version:
My idea is to create a subclass of each class that has changed (i.e. ProjectV2 extends Project, ProjectV3 extends ProjectV2 and so on), and when loading a project, read the version-number, load the appropriate class (i.e. ProjectV2) using hibernate, and then convert it to the current version using a constructor (i.e. ProjectV3).
My question is: Is there a better way to do this, or a feature in hibernate that makes this easier?
Thanks in advance!
|