In this example we have a Human class witch inherits from the Mammal class. Now we want to introduce a new Primate class and let the Human class inherit from it.
Unfortunately db4o doesn't support this kind of refactoring. We need to use a work-around. Basically we create a copy of the Human class with the new Inheritance-hierarchy and the copy the existing data over.
Now the objects have the new inheritance hierarchy. You can delete the old Human class.
ObjectSet<Human> allMammals = container.query(Human.class); for (Human oldHuman : allMammals) { HumanNew newHuman = new HumanNew(""); newHuman.setBodyTemperature(oldHuman.getBodyTemperature()); newHuman.setIq(oldHuman.getIq()); newHuman.setName(oldHuman.getName()); container.store(newHuman); container.delete(oldHuman); }
Note that this example doesn't change existing references from the old instances to the new ones. You need to do this manually as well.