Nathan E.
Nathan E.

Reputation: 55

Calling an Oracle Stored Function from Hibernate

I have an Oracle Editionalble Function (that I cannot change) which I need to call from Hibernate.

CREATE OR REPLACE EDITIONABLE FUNCTION
"SCHEMA"."FUNCTION_NAME"
(
  var1 IN CHAR DEFAULT NULL ,
  var2 IN CHAR DEFAULT NULL ,
  var3 OUT CHAR
)
RETURN NUMBER
AS
  ...
END;

Unfortunately, I have no idea how to do this. I saw a couple of posts on here about Session.doWork(), but I couldn't figure out how to make that work here.

Upvotes: 2

Views: 792

Answers (2)

Pankaj
Pankaj

Reputation: 645

You can try something like:

Query query = session.createSQLQuery(
    "CALL myfunc(:param1)")
    .setParameter("param1", "xyz");

Upvotes: 1

andy weiss
andy weiss

Reputation: 36

As long as the function does not change data you can use the dual table to call it from a query.

select schema.function_name(:bind1,:bind2,:bind3) from dual;

Upvotes: 1

Related Questions