ObjectDB ObjectDB

Automatic schema evolution causes ArrayOutOfBoundsException

#1

Hi,

I did 2 modification to our schema. Our schema looked like this:

class Entity
    - List<String> permissions
class ServiceProvider extends Entity
    - String name
class Airline extends Entity
    - String name
    - String iata

Now I changed the List<String> to List<Permission> (Permission is an embeddable class), the fields name remained untouched. After that I derived Airline from ServiceProvider and removed the duplicated name field, the schema now looks like this:

class Permission (@Embedded)
class Entity
   - List<Permission> permissions
class ServiceProvider extends Entity
    - String name
class Airline extends ServiceProvider
   - String iata

No fields or classes were renamed or moved to different packages.

If I now want to read an Airline object I get the following exception:

Caused by: java.lang.ArrayIndexOutOfBoundsException: 9
at com.mvolution.domain.entities.misc.ServiceProvider.__odbWriteContent(ServiceProvider.java:1) ~[classes/:na]
at com.mvolution.domain.entities.misc.Airline.__odbWriteContent(Airline.java:1) ~[classes/:na]
at com.objectdb.o.MMM.aj(MMM.java:1147) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.UTY.aD(UTY.java:1337) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.UTY.aC(UTY.java:1326) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.ENH.a(ENH.java:46) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.STA.U(STA.java:532) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.STM.E(STM.java:433) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.OBM.bP(OBM.java:931) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.jdo.PMImpl.bP(PMImpl.java:2279) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.OBM.bO(OBM.java:842) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.o.OBM.bM(OBM.java:751) ~[objectdb-mvolution-2.6.9_05.jar:na]
at com.objectdb.jpa.EMImpl.commit(EMImpl.java:287) ~[objectdb-mvolution-2.6.9_05.jar:na]

So it seems that both changes produce an unreadable database file. If I rename the permissions field to something else it works. The objectdb doctor states "No errors have been found". Is there any other way to resolve this schema update without renaming the permissions field?

Thanks for your help
Markus Ritter

edit
delete
#2

You describe two schema changes:

  1. Changing the type of the permissions field from List<String> to List<Permission>.
  2. Changing the hierarchy, making Airline a subclass for ServiceProvider and eliminating the duplicate name field.

According the ObjectDB schema evolution rules, the first change is not supported (since String and Pemission are not convertible types), so you will have to use a new field name, and write code to convert from List<String> to List<Permission>, possibly in a PostLoad callback method.

The second schema change is supported and should be handled automatically by ObjectDB, but you must rebuild your project and re-enhance all your classes after the change.

ObjectDB Support
edit
delete
#3

Hi,

thanks for the fast reply. I reworked my classes and now everything works as expected! 

Thanks
Markus

edit
delete

Reply

To post on this website please sign in.