I am creating a DB table using hbm2ddl with Java code similar to the following:
@Entity public class Filter { public enum Type { TypeA, TypeB; } @Enumerated(EnumType.STRING) private Type type; }
It works fine, but for "type" a VARCHAR column is created, that is, the DDL code looks like this:
CREATE TABLE IF NOT EXISTS `filter` (`type` varchar(255) DEFAULT NULL)
But I want it to be:
CREATE TABLE IF NOT EXISTS `filter` (`type` enum('TypeA','TypeB') NOT NULL)
Is it possible to declare in Hibernate, preferably with annotations?
Or is there a way to extend SchemaUpdate and overwrite the method that displays the alter script part for an enum field as I like?
Background: the same database is used in part of the PHP project, and I want these invalid values ββto be inserted.
Simon source share