Hello all,
I am trying to do a query from an Oracle function and am tearing my hair out trying to figure out the answer. I am using Hibernate v2 and want to find the result from the following:
Code:
SELECT pkgName.pkgFunction FROM dual WHERE rownum = 1
Basically there is a Oracle Package that contains a Function I need to call. I would prefer not to have to bother the DBA to write a Procedure to wrap this. I saw you can do a <sql-query> with { ? = call ProcedureName } but I cannot find something equivocal to an Oracle Function in the examples.
The return type from the Function is an Integer and (obviously) it only has one row. I have tried various things, such as <query> and using session.getNamedQuery() and hardcoding the SQL into a session.createQuery("SELECT...") but it usually results in Hibernate complaining when it tries to map the pkgName to an alias. I even tried giving the Function call an alias to no avail:
Code:
SELECT pkgName.pkgFunction AS XXX FROM dual WHERE rownum = 1
and then creating a corresponding XXX.hbm.xml mapping file for it -- but it still complains when it tries to rewrite the SQL that 'pkgName' is an invalid alias. Does anyone have an example Oracle Function in a Package query mapping using the DUAL table they could provide?
P.S. - I would prefer not to have to upgrade to Hibernate v3 (especially since they changed all the package names, ugh!) but if it is required I can.