From: Oliver Jowett <oliver@opencloud.com>
To: stagirus <mamasa@stagirus.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
Date: Wed, 06 Oct 2010 00:05:27 +1300
Message-ID: <4CAB0677.5080706@opencloud.com> (raw)
In-Reply-To: <1286275310520-3199236.post@n5.nabble.com>
References: <4CA499DB.8000807@postnewspapers.com.au>
<4CA4F536.5050704@opencloud.com>
<1285880740264-3047671.post@n5.nabble.com>
<4CA503A2.7010706@opencloud.com>
<1285883402563-3047721.post@n5.nabble.com>
<4CA55A9E.80700@postnewspapers.com.au>
<1285971439496-3073409.post@n5.nabble.com>
<4CA6929B.5050105@postnewspapers.com.au>
<1285995027439-3073605.post@n5.nabble.com>
<AANLkTi=wYc=JOcXUY4ZmrLjYJfsv9d-iy82bUt9hsTiW@mail.gmail.com>
<1286275310520-3199236.post@n5.nabble.com>
stagirus wrote:
> Good morning. Please find the attached log file regarding our problem. The
> main issue is with "DELETED" column as SMALLINT. Postgres is not accepting
> '0' in the values(..) for DELETED column. (This was the original issue that
> I posted.)
>
> http://postgresql.1045698.n5.nabble.com/file/n3199236/PostgresForum.log
> PostgresForum.log
> ERROR 04-10 15:26:32,937 (JDBCExceptionReporter.java:logExceptions:101) -Batch entry 0 /* insert com.stagirus.subsystem.suppliermaster.domain.Provider */ insert into ST_PROVIDER (GEOGRAPHY_ID, ADDRESS_ID, PROVIDER_NAME, DESCRIPTION, WEBSITE, EMAIL, PHONE, FAXNO, PRIMARY_ORG_ID, DELETED, CREATED_ON, CREATED_BY, LAST_MODIFIED_ON, LAST_MODIFIED_BY, PROVIDER_ID) values ('1', '2', 'supplier1', NULL, NULL, NULL, '1245874123', '', '1', '0', '2010-10-04 15:26:32.734000 +05:30:00', '1', '2010-10-04 15:26:32.734000 +05:30:00', '1', '1') was aborted. Call getNextException to see the cause.
Not shown in your logs is the type which Hibernate is binding the
parameters as. I expect that the '0' is actually bound with Oid.BOOL
because Hibernate is using setBoolean() or setObject(...,Types.BOOLEAN).
For example, the implementation of setBoolean does this:
> public void setBoolean(int parameterIndex, boolean x) throws SQLException
> {
> checkClosed();
> bindString(parameterIndex, x ? "1" : "0", Oid.BOOL);
> }
which means that the value parameter is indeed "0" or "1" - but its type
is BOOL. (I'm guessing that the query logged by Hibernate above is the
result of PreparedStatement.toString(), which just substitutes the raw
parameter values into the query string without respect for their bound
types)
You could check this by setting loglevel=2 and looking at the messages
sent to the backend, or by looking at a packet capture with wireshark
(IIRC, it has a decent protocol analyzer for the postgresql FE/BE protocol)
Oliver
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: oliver@opencloud.com, mamasa@stagirus.com
Subject: Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)
In-Reply-To: <4CAB0677.5080706@opencloud.com>
References: <4CA499DB.8000807@postnewspapers.com.au> <4CA4F536.5050704@opencloud.com> <1285880740264-3047671.post@n5.nabble.com> <4CA503A2.7010706@opencloud.com> <1285883402563-3047721.post@n5.nabble.com> <4CA55A9E.80700@postnewspapers.com.au> <1285971439496-3073409.post@n5.nabble.com> <4CA6929B.5050105@postnewspapers.com.au> <1285995027439-3073605.post@n5.nabble.com> <AANLkTi=wYc=JOcXUY4ZmrLjYJfsv9d-iy82bUt9hsTiW@mail.gmail.com> <1286275310520-3199236.post@n5.nabble.com> <4CAB0677.5080706@opencloud.com>
* 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