Re: Postgres SQL unable to handle Null values for Text datatype

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Karthik K L V <venkata(dot)karthik4u(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Postgres SQL unable to handle Null values for Text datatype
Date: 2022-09-06 13:38:35
Message-ID: FFAFDCD7-AB02-4606-8D51-9F89EC5696B1@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Sep 5, 2022, at 23:10, Karthik K L V <venkata(dot)karthik4u(at)gmail(dot)com> wrote:
> The above query fails with the below exception when the value of ?1 resolves to null.
> org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bytea
> Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
> Position: 64

This is a Hibernate issue. If you use setParameter with a NULL without specifying the type, it assumes bytea (with the PostgreSQL JDBC driver, at least). You'll need to use the three-parameter form of setParameter() that specifies a type, if the value is going to be NULL. You can also use the setXXXX methods on SQLQuery, since the type is specified by the particular method there.

That being said, PostgreSQL's handling of NULL string values is different from Oracle's, and this is an area that code changes are often required.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeffrey Walton 2022-09-06 14:13:29 Re: Determine if a user and database are available
Previous Message Mladen Gogala 2022-09-06 12:57:23 Re: Postgres SQL unable to handle Null values for Text datatype