Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 969
Pramod Karandikar Avatar asked Oct 21 '25 09:10

Pramod Karandikar


1 Answers

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.

like image 145
Vlad Mihalcea Avatar answered Oct 23 '25 01:10

Vlad Mihalcea



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!