Home » Support » Forum » mismatch after Enum changes

mismatch after Enum changes

#1

Hi,

I have an entity, an attribute is a enum type:

public enum MyEnum {
  AA, BB, CC, DD;
}

I populated the database, than I changed the enum types deleting some unused types (es. AA) without reset database:  

public enum MyEnum {
  BB, CC, DD;
}

Now there are mismatches with enums in database. It looks as if objectdb keeps the "position" of enum. For example: attributes of entity set to ENUM.BB (second position before the change) now are set to ENUM.CC (second position after the change).

It is a correct behaviour?

Thanks in advance!

#2

Yes, this is the default behavior. Enum values are stored as ordinal number by default, and then you must preserve the position of every existing value.

Alternatively you can opt for storing enum values as strings. See the documentation for more details.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login