Hi,
i'm using postgreSQL 9 and hibernate 3. In my database i have a function/procedure that recives several parameters, one of them an array. The function signature:
Code:
function calc(integer, integer, double precision, double precision, integer[])
Inside the function this array is used in the where clause like:
Code:
where type = any(types)
where type is the colum name of the table and types is the array in value.
I'm trying to call it with a named query like this:
Code:
<sql-query name="query">
<return mapping>
select * from calc(:id1, :id2, :val1, :val2, :types)
</sql-query>
And setting parameters in java like:
Code:
Integer[] types = new Integer[]{1, 2};
Query query = session.getNamedQuery("query");
query.setParameter("id1", id1);
query.setParameter("id2", id2);
query.setParameter("val1", val1);
query.setParameter("val2", val2);
query.setParameterList("types", types);
But it's failling. I can see that hibernate is trying to call the procedure as:
Code:
function calc(integer, integer, double precision, double precision, integer) -- With the types integer array of length 1
function calc(integer, integer, double precision, double precision, integer, integer) -- With the types integer array of length 2
So i guess i'm doing it wrong. Wich is the correct way for calling such function? Is there a wayaround to achieve the same behaviour?
Thanks in advance.
Javi