How to use functions in the select clause of a NamedQuery in JPA
Posted on 2008-06-11
We are in the process of migrating an application to JPA(Hibernate implementation).
Previously the application was using direct sqls.
One of the table has it's data in encrypted format using Oracle DES encryption.
The encryption logic has been implemented in a user defined oracle encrypt function and it is invoked in the trigger.
The decryption is done while fetching the data by invoking the user defined oracle decrypt function in the
select clause, some thing like this:
select id, decrypt(name) as name, decrypt(location) as location from Company
Now as we are migrating the application to JPA, I'm having difficulty in fetching the data from this table.
The encryption works fine as usual with by the triggers. But I do not know how to call the decrypt function when we
fetch the Company entities.
Is it possible to use the oracle functions in the NamedQuery's select clause. If so, how? Or is there any other way
to do this?
Your help is much appreciated.