Hibernate: Case insensitive EnumType fields?

I'm working on a legacy DB I have no control over, in my code I have an entity "User" which is mapped to a table in the DB, User has a User.role field, this filed is an Enum:


public enum UserRole{ ADMIN,SUPERADMIN.....}

User has the following mapping


private UserRole role;

the problem is that the DB is inconsistent, in the DB i might some times get user_type as one of the following:


  1. Admin
  2. admin
  3. ADMIN

for the first two cases I will get an exception since hibernate would not fine matching Enum

Is there a simple way to tell hibernate to ignore cases for this enum? I know I can probably extned Hibernate's EnumType and modify it but I was wondering if there's a simple solution.

Thanks in advance,


Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com