Issue
My goal is to create an @Entity
that auto-generates the following table with hibernate:
CREATE TABLE data_history (
id bigint auto_increment,
action enum('INSERT','UPDATE','DELETE'),
PRIMARY KEY(id)
);
Problem is the enum: how can I tell hibernate to generate that enum type?
I tried as follows:
@Entity
public class DataHistory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public long id;
@Enumerated(EnumType.STRING)
public DatabaseTrigger action;
}
public enum DatabaseTrigger {
INSERT, UPDATE, DELETE
}
Result:
action varchar(255) NOT NULL
Solution
That is not yet possible. Maybe in 6.x we will introduce support for this, but right now, you would have to do this manually.
Answered By - Christian Beikov