pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: smallint vs. boolean (was invalid string enlargement
3+ messages / 2 participants
[nested] [flat]

* Re: smallint vs. boolean (was invalid string enlargement
@ 2005-04-12 17:05  Glenn Holmer <gholmer@weycogroup.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Glenn Holmer @ 2005-04-12 17:05 UTC (permalink / raw)
  To: pgsql-jdbc

On Fri, 2005-03-18 at 09:37 +1300, Oliver Jowett wrote:
> Glenn Holmer wrote:
> 
> > We can't upgrade the driver because we get this:
> > 
> > 2005-03-17 10:10:22,961 WARN  
> > net.sf.hibernate.util.JDBCExceptionReporter - Meth
> > od: logExceptions - Line: 38  Message: SQL Error: 0, SQLState: 42883
> > 2005-03-17 10:10:22,962 ERROR 
> > net.sf.hibernate.util.JDBCExceptionReporter - Meth
> > od: logExceptions - Line: 46  Message: ERROR: operator does not exist: 
> > smallint = boolean
> 
> Without more details I'd have to say this is a hibernate or schema 
> mapping bug -- it looks like it is using setBoolean() where you should 
> be using setShort() (or vice versa). This only shows up in newer drivers 
> because they more tightly bind types to parameters (due to using the V3 
> extended query protocol to pass parameters to the server)
> 
> This behaviour is unlikely to change, so you might want to look at 
> tracking down the cause. As a last resort, you might be able to create 
> implicit casts between smallint<->boolean.

Yes, the database has some fields defined as smallint and set to 0 for
false or either 1 for true; the Hibernate DTOs have these fields
declared as boolean.

Is there any way around this without rewriting everything?

-- 
____________________________________________________________
Glenn Holmer                          gholmer@weycogroup.com
Software Engineer                        phone: 414-908-1809
Weyco Group, Inc.                          fax: 414-908-1601





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: smallint vs. boolean (was invalid string enlargement
@ 2005-04-12 22:09  Oliver Jowett <oliver@opencloud.com>
  parent: Glenn Holmer <gholmer@weycogroup.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliver Jowett @ 2005-04-12 22:09 UTC (permalink / raw)
  To: Glenn Holmer <gholmer@weycogroup.com>; +Cc: pgsql-jdbc

Glenn Holmer wrote:
> On Fri, 2005-03-18 at 09:37 +1300, Oliver Jowett wrote:

>>This behaviour is unlikely to change, so you might want to look at 
>>tracking down the cause. As a last resort, you might be able to create 
>>implicit casts between smallint<->boolean.
> 
> 
> Yes, the database has some fields defined as smallint and set to 0 for
> false or either 1 for true; the Hibernate DTOs have these fields
> declared as boolean.
> 
> Is there any way around this without rewriting everything?

Change the column type so it is a boolean, change the hibernate mapping
so it calls setShort(), or create the implicit cast as I suggested.

-O



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: smallint vs. boolean (was invalid string enlargement
@ 2005-04-13 16:02  Glenn Holmer <gholmer@weycogroup.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Glenn Holmer @ 2005-04-13 16:02 UTC (permalink / raw)
  To: pgsql-jdbc

On Wed, 2005-04-13 at 10:09 +1200, Oliver Jowett wrote:

> Change the column type so it is a boolean, change the hibernate mapping
> so it calls setShort(), or create the implicit cast as I suggested.

I got it to work with some PL/pgSQL functions, implicit casts, and
overloading the = operator (smallint, boolean).  I'll strongly recommend
to the vendor that they rewrite the Postgres DDL for their product to
use booleans for boolean fields, but in the mean time are there any side
effects I should worry about?

-- 
____________________________________________________________
Glenn Holmer                          gholmer@weycogroup.com
Software Engineer                        phone: 414-908-1809
Weyco Group, Inc.                          fax: 414-908-1601





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-04-13 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-04-12 17:05 Re: smallint vs. boolean (was invalid string enlargement Glenn Holmer <gholmer@weycogroup.com>
2005-04-12 22:09 ` Oliver Jowett <oliver@opencloud.com>
2005-04-13 16:02   ` Glenn Holmer <gholmer@weycogroup.com>

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