Hibernate and Oracle hidden features

I have an object that maps to an external oracle table which is one of the main data sources of my application. This object is modeled using hibernation.

The oracle table now has a complex function that defines the computation of some special values. I need to call this function somehow - almost like another accessor on the object.

What would you suggest is the best way to enable this function call so that I can maintain relatively normal hibernate access to objects?

+1


source to share


3 answers


I have a solution using @Formula annotation



+1


source


To keep the decoupling from your Hibernate-provided database, I would rely on Oracle to call this function using triggers or views.



The main advantage of this approach is that it is fully compatible with your Hibernate implementation.

+1


source


You can call the function directly using a stored procedure using HQL. Unless, of course, you have to call this function for every record in the table. But if you are doing this in a single hibernation session, as long as you are not making many calls at the same time, it should work without significantly improving performance.

0


source







All Articles