Skip to content
Advertisement

MySQL to Hibernate datatype mapping for type “YEAR”

There’s a column in our database which needs to be of type YEAR. What is the corresponding Hibernate mapping for the entity? Tried searching all over, but unable to find the details. I am not sure if I need to use anything from @Temporal or any other specific type. We are using Hibernate ORM v4.1.7.

Advertisement

Answer

You can write a Hibernate UserType that takes an Integer to a MySQL YEAR column.

Check for example Joda Hibernate UserTypes which are a good starting point for your custom Hiberante type.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement