xhange classes attributes in existing db4o in android
I'm considering to use db4o in my android project to store objects but my concern is if in the future I want to change one of the objects attributes how do i deal with the existing data of that object in the db4开发者_Go百科o file? I know in sqlite3 environment this can be done by altering the table structure in the onUpgrade() method, so how does db4o deal with this?
in db4o it really depends on what the changes are.
- Adding field: You just add it. The new field will have the default value of that type. (null for references, 0 for numbers)
- Removing a field: db4o will just ignore the removed field. You can access the old data of the removed field. As soon as you update the object the value of the old field will be removed.
- Renaming fields and classes can be done with this call.
- Changing the type of a field. That's like adding a new field. You need to copy the values over yourself. See here.
- Adding interfaces has no effect on db4o.
- Removing a type from the inheritance hirarchy: Not supported.
In general, take a look here.
精彩评论