Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2D6131337B4E for ; Wed, 29 Sep 2010 14:58:36 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 45509-10 for ; Wed, 29 Sep 2010 17:58:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kickstone.com (87-194-183-70.dsl.cnl.uk.net [87.194.183.70]) by mail.postgresql.org (Postfix) with ESMTP id 924F81337B3E for ; Wed, 29 Sep 2010 14:58:28 -0300 (ADT) Received: from 79-69-178-76.dynamic.dsl.as9105.com ([79.69.178.76]:54213 helo=[192.168.6.15]) by mail.kickstone.com with esmtpa (Exim 4.69) (envelope-from ) id 1P10c5-0000bM-IO for pgsql-jdbc@postgresql.org; Wed, 29 Sep 2010 18:38:41 +0100 Message-ID: <4CA37E4C.10306@kickstone.com> Date: Wed, 29 Sep 2010 18:58:36 +0100 From: John Lister User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: selecting using array as IN condition parameter - possible? Content-Type: multipart/alternative; boundary="------------050703090005070108020305" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.917 tagged_above=-10 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, RDNS_DYNAMIC=0.982 X-Spam-Level: X-Archive-Number: 201009/84 X-Sequence-Number: 20954 This is a multi-part message in MIME format. --------------050703090005070108020305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, after some more searching on the net I came across references to PGobject and got this working using standard JDBC calls which is a good start, I don't suppose any one has any hints about using this in JPA queries under eclipselink? I've created a converter for the single case, but i get errors when I try and use an array. If I try and receive an array I get a not implemented error on getArrayImpl due to the use of a Map. Conversely if I construct an array of my PGobjects subclasses and try to pass that as a parameter to a query I get an exception that setObject can't infer the sql type needed and to provide an explicit one. I was hoping that as PGobject has a getType method that it would be used? Is it possible to specify the type when passing an array using JPA? Thanks John On 29/09/2010 13:59, John Lister wrote: > Hi, suppose I have a query such as > select * from blah where (a,b) in ( (1,2),(2,3),(3,4)...) > I'd like to do this using jdbc and use a list/array for the IN parameter. > using postgresql 8.3, it is possible to rewrite it so that I am > passing in an array instead of a hardcoded list as so > select * from blah where (a, b)::myPairType = any ( array of myPairType) > provided I've created a type (myPairType) to represent my data pair > and a comparison operator for the new data type. > My question is therefore is it possible to pass an array of this type > using jdbc or alternatively pass an array of arrays to represent my > pair and convert that in the sql? > Thanks > John > -- > Got needs? Get Goblin'! - http://www.pricegoblin.co.uk/ --------------050703090005070108020305 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, after some more searching on the net I came across references to PGobject and got this working using standard JDBC calls which is a good start, I don't suppose any one has any hints about using this in JPA queries under eclipselink? I've created a converter for the single case, but i get errors when I try and use an array.

If I try and receive an array I get a not implemented error on getArrayImpl due to the use of a Map. Conversely if I construct an array of my PGobjects subclasses and try to pass that as a parameter to a query I get an exception that setObject can't infer the sql type needed and to provide an explicit one. I was hoping that as PGobject has a getType method that it would be used?

Is it possible to specify the type when passing an array using JPA?

Thanks

John


On 29/09/2010 13:59, John Lister wrote:
Hi, suppose I have a query such as
 
select * from blah where (a,b) in ( (1,2),(2,3),(3,4)...)
 
I'd like to do this using jdbc and use a list/array for the IN parameter.
 
using postgresql 8.3, it is possible to rewrite it so that I am passing in an array instead of a hardcoded list as so
 
select * from blah where (a, b)::myPairType = any ( array of myPairType)
 
provided I've created a type (myPairType) to represent my data pair and a comparison operator for the new data type.
 
My question is therefore is it possible to pass an array of this type using jdbc or alternatively pass an array of arrays to represent my pair and convert that in the sql?
 
Thanks
 
John
--
 
Got needs? Get Goblin'! - http://www.pricegoblin.co.uk/
--------------050703090005070108020305--