Question

I am trying to use JBoss envers (4.2.0.FINAL) annotations on my project but I failed due to an Enum auditing problem,

My entity code is

@Entity
@Audited
@DiscriminatorValue("CREDIT")
@EqualsAndHashCode(callSuper = true)
@Data
public class CreditTransactionEntity extends TransactionEntity {

    @Column(name = "consumed")
    protected int consumed;

    @Column(name = "approval_status", columnDefinition = "ENUM('APPROVED', 'DISAPPROVED', 'PENDING') DEFAULT 'PENDING'")
    @Enumerated(EnumType.STRING)
    private ApprovalStatus status;

    public enum ApprovalStatus {
       APPROVED, DISAPPROVED, PENDING
    }
 }

But when ever I update/insert a record the following exception appears

JDBC exception on Hibernate data access: SQLException for SQL [n/a]; SQL state [S1000]; error code [0]; Cannot convert class java.lang.String to SQL type requested due to java.lang.NumberFormatException - For input string: "APPROVED"; nested exception is org.hibernate.exception.GenericJDBCException: Cannot convert class java.lang.String to SQL type requested due to java.lang.NumberFormatException - For input string: "APPROVED"

Why it cast an enum to integer ?!

Note: I am using hibernate 4.1.8.Final

Was it helpful?

Solution

It look like a versioning compatibility bug,

I upgrade my hibernate-entitymanager from 4.1.8.Final to 4.2.0.Final and everything is working fine now

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top