tags:

views:

1056

answers:

1

I have a database table using an enum. This is already working with hibernate (using XML), and I'm trying to convert it to annotations as this is one of the last pieces to still be using xml notation.

The column definition:

enum('Active','Pending','Cancelled','Suspend')

The following works:

<property
    name="status"
    column="STATUS"
    type="string"
    not-null="true" />

This does not work:

@Column(name = "status")
public String status;

The annotation-style leads to the following exception upon startup: org.hibernate.HibernateException: Wrong column type in UserDTO for column status. Found: enum, expected: varchar(255)

Is there any way for me to force this to accept a String as it did using the XML notation?

+1  A: 

I figured it out. It should be:

@Column(name="status", columnDefinition="enum('Active','Pending','Cancelled','Suspend')")
public String status;
Jesse