Can I store enum as ordinal instead of string in JaVers?

128 Views Asked by At

I use JaVers 6.10.0 in Spring Boot to store versions of this class:

class AUserBusinessData {

  @Id
  @PropertyName("i")
  private Long id;

  @PropertyName("s")
  JHAEUserStatus status;

}

public enum JHAEUserStatus {
    ACTIVE,
    INACTIVE,
}

JaVers stores this in the STATE column of the JV_SNAPSHOT table as follows:

{
  "i": 1202,
  "s": "ACTIVE",
}

Is there a way for me to store the enum as an ordinal (i.e, 0 or 1 in this case) instead of a string (e.g. "ACTIVE", as seen above)?

1

There are 1 best solutions below

1
On

There is no such option out-of-the-box. You can try to write custom JSON Type Adapter, one per each enum type.