There are two t_statuses and t_operators . In the first value (-1 - BANNED, 0 - OFFLINE, 1 - ONLINE) , in the second, the actual operators, whose status is the foreign key ( status_id ) on the first table. In java code, I instead of the entity class for statuses made enum:
public enum OperatorStatus { BANNED(-1), OFFLINE(0), ONLINE(1); private int id; OperatorStatus(int id) { this.id = id; } public int getValue() { return id; } } The database has one entry with the status 0 - OFFLINE . If in the Operator class the status field is made the type Integer, then 0 is set to it. But, if I create a field of type OperatorStatus , its value becomes equal to BANNED , i.e. -one. What is the reason for this difference?