From: Christophe Pettus <xof@thebuild.com>
To: Karthik K L V <venkata.karthik4u@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Postgres SQL unable to handle Null values for Text datatype
Date: Tue, 6 Sep 2022 06:38:35 -0700
Message-ID: <FFAFDCD7-AB02-4606-8D51-9F89EC5696B1@thebuild.com> (raw)
In-Reply-To: <CAGpQzhyO=2r74uWmbStYN4VSGhxD1_zmftdFcbf94dznLA42xQ@mail.gmail.com>
References: <CAGpQzhyO=2r74uWmbStYN4VSGhxD1_zmftdFcbf94dznLA42xQ@mail.gmail.com>
> On Sep 5, 2022, at 23:10, Karthik K L V <venkata.karthik4u@gmail.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.
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-general@postgresql.org
Cc: xof@thebuild.com, venkata.karthik4u@gmail.com
Subject: Re: Postgres SQL unable to handle Null values for Text datatype
In-Reply-To: <FFAFDCD7-AB02-4606-8D51-9F89EC5696B1@thebuild.com>
References: <CAGpQzhyO=2r74uWmbStYN4VSGhxD1_zmftdFcbf94dznLA42xQ@mail.gmail.com> <FFAFDCD7-AB02-4606-8D51-9F89EC5696B1@thebuild.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