Please help on how to ignore match case for serializable id on the session.get()
method in hibernate. I don't want to handle at the criteria, I need it at the session.get()
method.
User user = (User ) session.get(User.class, id);
Eg: US123
and us123
as id should give me a result.
There is no way to get it out of the box, because those are two different ids (you could have two distinct users with ids US123
and us123
).
You can however make sure that you always store uppercase (or lowercase, whatever you prefer) ids when you create users; then you could fetch users by id like this:
User user = (User ) session.get(User.class, id.toUpperCase());