Hibernate / JPA Error - Not Recognizing Some Lines in an Enumeration

I have an enumeration in the class displayed by Hibernate. One of the displayed fields is the enumeration type, which has one of the following OK , NOK, or NAP values . NOK or NAP works as expected, but when the field in which the class is set is set to OK, Hibernate does not display or retrieve the value that is set to null:

java.lang.IllegalArgumentException: Unknown name value for enum class     com.a.b.c.d.Class$Status: OK
    at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:113)

The class has:

private Status status;

@JoinColumn(name = "STATUS")
@Enumerated(EnumType.STRING)
public Status getStatus() {
    return status;
}

public enum Status {
    OK, NOK, NAP;
}

OK OK2, . _OK . , "" (, ) .

!

UPDATE:

Up ' , , _OK' ' ', . , .

public enum Status {
    _OK("OK"), 
    NOK("NOK"), 
    NAP("NAP");

    private String desc;

    private Status(String desc){
        this.desc = desc;
    }

    public String getDesc(){
        return desc;
    }
}

BUG:

A .

+5
3

, , OK, NOK, NAP , , .

Exception com.a.b.c.d.Class$Status: OK2 , , , java.lang.IllegalArgumentException: Unknown name value for enum class.

, / .

+10

VARCHAR:

@Column(columnDefinition = "VARCHAR(3)")
// @Column(columnDefinition = "VARCHAR2(3)") // VARCHAR2 for Oracle
@Enumerated(EnumType.STRING)
public Status getStatus() {
    return status;
}

public enum Status {
    OK, NOK, NAP;
}
+3

HSQLDB 1.8 2.2.6. Hibernate CHARACTER, ( VARCHAR). , , . INSERT/UPDATE Hibernate, .

, , HSQLDB . , , HSQLDB, Hibernate. , HSQLDB SQL, Hibernate EnumType .

+1

All Articles