pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Steven Dahlin <pgdb.sldahlin@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PSQLException Can't infer the SQL type to use with Native Query call
Date: Tue, 03 May 2011 09:33:07 +0800
Message-ID: <4DBF5B53.2000009@postnewspapers.com.au> (raw)
In-Reply-To: <BANLkTikkkT=94ZcRy2DijZ2UBgLY7tvTZA@mail.gmail.com>
References: <BANLkTikkkT=94ZcRy2DijZ2UBgLY7tvTZA@mail.gmail.com>

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



view thread (2+ messages)

Message-ID: <4DBF5B53.2000009@postnewspapers.com.au>
Permalink:  ../4DBF5B53.2000009@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4DBF5B53.2000009@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: craig@postnewspapers.com.au, pgdb.sldahlin@gmail.com
  Subject: Re: PSQLException Can't infer the SQL type to use with Native Query call
  In-Reply-To: <4DBF5B53.2000009@postnewspapers.com.au>
  References: <BANLkTikkkT=94ZcRy2DijZ2UBgLY7tvTZA@mail.gmail.com> <4DBF5B53.2000009@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox