We are working on an payment application based on spring-boot 2.5.6. The application is hosted on docker and launched on Java 14. We created an abstract class named GeneralEnum which is @Embeddable and contains two variables int type and String value. All enumeration classes extend this base class and define constants inside it.
This decision is made to customize enumeration used in whole layer of application. You can see one example in below:
@Embeddable
public class ShapeEnum extends GeneralEnum {
public static final ShapeEnum CIRCLE = new ShapeEnum(0, 'Circle');
public static final ShapeEnum RECTANGLE = new ShapeEnum(1, 'Rectangle');
public ShapeEnum(int type, String value) {
super(type, value);
}
}
This class is used in entity layer as embedded variable as follow:
@Entity
public class Shape {
@Embedded
@AttributeOverride(name = "type", column = @Column(name = "shape_type"))
private ShapeEnum shapeType;
}
The system worked perfectly, but something wrong happens and the value field of ShapeEnum.RECTANGLE changed to Circle and type is changed to 0 (!!!) and after that system would fail (dumping RAM shown the change of value). As I tracked, the problem is occurred after running GC and when the ShapeEnum is not used for a while.
Would anyone make an idea what happens and how tackle this problem? For now, restarting docker container causes the app will work properly.
Thanks in advance.
---------------
The dump for another class is (TicketStatus class) shown below. The highlighted part is changed without reason. The first and second constants' value and type are the same. I am sure that setValue and setType won't call in the source-code.

enums butclasses?int typelike field into db. We have so many enumeration and cant use serializer and deserializer like approach.