Hi:
We are storing encrypted data in the tables. The encryption and decryption code is written in Java and is done before and after saving/retrieving data from the DB.
I am looking for a way to be able to query the database with a like statement. For example, if userName column in the table is storing encrypted data, is there a way to be able to query userName like '%xyz%'. As the data stored in userName column is encrypted byte data, simple select will not work. So I should be able to call a Java method to decrypted the data by calling a Java class in the select statement and do a like comparison.
I am using Hibernate named queries and therefore I would like to do something as follows:
Code:
select user from user myUser where com.myApp.Security.decrypt(myUser.userName) like '%xyz%
where
com.myApp.Security.decrypt is a method in Security Java class which will know how to decrypt the byte data stored in the database to a String.
Is there a way to call a Java method embedded within the name query?
Or could you please provide any other way to accomplish what I am trying to do.
Your help is greatly appreciated.
Thanks
Ram