I have a Java Entity with a field with the annotation @Formula, in which is executed an SQL query containing some specific function for Firebird database. Now I have to migrate to Oracle database, and I need to replace the SQL code inside that @Formula. Is there a way to achieve this ? Can I extend in some way the Hibernate @Formula in order to change the annotation's value at runtime ? Thanks
You can achieve this slightly different way.
You can place in the @Formula
a placeholder "{TO_BE_REPLACED}"
and add a Hibernate Interceptor to change onPrepareStatement.
There you can can change SQL generated by hibernate. JUst check the SQL string and replace the {TO_BE_REPLACED}
with your real value.
See how to add interceptor here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With