-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Calling function with primitive array as parameter
PostPosted: Thu Jun 21, 2012 3:37 am 
Newbie

Joined: Wed Jun 06, 2012 11:47 am
Posts: 6
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.