We are having old data in our schema with spaces in the Var char fields, most of them are duplicate. We wanted to merge these duplicate data some time. Also we want to make sure that until we merge this data user should not be able to create such duplicate data again.
We tried investigating whether hibernate supports this but we are not able to find any solution. After some Google, we find REPLACE or REGEXP_REPLACE function can be used to replace all the white space or regex characters chars from the var char field in SQL. We tried same function in the HQL and it worked like a charm.
I am writing this blog hoping this may be helpful for some one else as well.
Common Solution