Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3F6981337B3E for ; Mon, 2 May 2011 22:33:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 82350-04 for ; Tue, 3 May 2011 01:33:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id EDBE8133798E for ; Mon, 2 May 2011 22:33:08 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id 5F0A8882; Mon, 2 May 2011 21:33:09 -0400 (EDT) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id eLAykcUmCmUf; Mon, 2 May 2011 21:33:08 -0400 (EDT) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id A9C7127; Mon, 2 May 2011 21:33:08 -0400 (EDT) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id ABA3A2012; Tue, 3 May 2011 09:33:07 +0800 (WST) Message-ID: <4DBF5B53.2000009@postnewspapers.com.au> Date: Tue, 03 May 2011 09:33:07 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Thunderbird/3.1.9 MIME-Version: 1.0 To: Steven Dahlin CC: pgsql-jdbc@postgresql.org Subject: Re: PSQLException Can't infer the SQL type to use with Native Query call References: In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/2 X-Sequence-Number: 21832 On 03/05/11 02:03, Steven Dahlin wrote: > In trying to call a postgresql 8.4 stored function I am passing a > class as well as a List (I have to save a master record as well as the > detail records). This is being done with a native query using > EclipseLink 2.1. However, I am getting back a message for the first > item: > > PSQLException: Can't infer the SQL type to use for an instance of > com.hwcs.veri.shared.dto.MyClass. Use setObject() with an explicit > Types value to specify the type to use. > > I am calling the query setting up the parameter with: > > query.setParameter( 1, myClass ); You'll have to translate 'MyClass' to a SQL type representation (say, 'text') yourself, use a form of query.setParameter() that takes a javax.sql.Types argument allowing you to specify the SQL type, or write a mapping for ExclipseLink to support your data type. The JDBC interface doesn't really understand complex types, record representations, etc. Because EclipseLink tries to use only the basic, widely supported features of JDBC you can't easily use PgJDBC extensions to map between PostgreSQL types and Java types directly. -- Craig Ringer