34 lines
949 B
Java
34 lines
949 B
Java
|
package org.warp.jcwdb.tests;
|
||
|
|
||
|
import org.warp.cowdb.EnhancedObject;
|
||
|
import org.warp.cowdb.EnhancedObjectUpgrader;
|
||
|
import org.warp.jcwdb.ann.DBClass;
|
||
|
import org.warp.jcwdb.ann.DBDataType;
|
||
|
import org.warp.jcwdb.ann.DBField;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
|
||
|
@DBClass(version = 1)
|
||
|
public class V2Class extends EnhancedObject {
|
||
|
@DBField(id = 0, type = DBDataType.LONG)
|
||
|
public long field1;
|
||
|
|
||
|
@DBField(id = 1, type = DBDataType.INTEGER)
|
||
|
public int field2;
|
||
|
|
||
|
@DBField(id = 3, type = DBDataType.OBJECT)
|
||
|
public String field4;
|
||
|
|
||
|
@Override
|
||
|
public void onUpgrade(int oldObjectVersion, EnhancedObjectUpgrader enhancedObjectUpgrader) throws IOException {
|
||
|
switch (oldObjectVersion) {
|
||
|
case 0: {
|
||
|
field1 = (long) (Integer) enhancedObjectUpgrader.getField(3, DBDataType.INTEGER);
|
||
|
field2 = (int) enhancedObjectUpgrader.getField(1, DBDataType.INTEGER);
|
||
|
field4 = (String) enhancedObjectUpgrader.getField(0, DBDataType.OBJECT);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|