Tuesday, 15 May 2012

Hibernate Enum mapping not creating mysql enum -



Hibernate Enum mapping not creating mysql enum -

i'm using hibernate mysql. i'm trying map enum type, according several examples seems straight forward.

however, column generated contains varchar(255) rather enum type expected.

here's simple enum class.

public enum gender { male, female }

here's annotation

@enumerated(enumtype.string) @column(name = "gender") public gender getgender() { homecoming gender; }

and here's field that's generated this

| gender | varchar(255) | no | | null | |

i can't see why type string rather enum. i've tried changing enum type ordinal, integer rather string, still no enum.

any help appreciated.

i don't think it's possible because enum not standard sql datatype. default @enumerated mapped integer, if enumtype.string used column mapped string.

hibernate

No comments:

Post a Comment