From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: tareque.bracu@gmail.com
Subject: BUG #17427: ERROR: cannot cast type bytea to bigint
Date: Sun, 06 Mar 2022 06:29:45 +0000
Message-ID: <17427-e6d4cf0807ba4424@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 17427
Logged by: Ahmed Tareque
Email address: tareque.bracu@gmail.com
PostgreSQL version: 14.0
Operating system: Windows
Description:
Error :
SQL Error: 0, SQLState: 42846.
ERROR: cannot cast type bytea to bigint
could not extract ResultSet; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
My Query :
@Query(value = "SELECT tam.name, tm.* FROM tam_main AS tm " +
"LEFT JOIN tam_occupation AS tam ON tam.id =
tm.tam_occupation_id " +
"LEFT JOIN tam_type AS tap ON tap.id = tm.tam_type_id " +
"WHERE (:occupationName is null or (LOWER(tam.name) LIKE '%' ||
cast(:occupationName AS text) || '%' ) )" +
"AND (:tamTypeId is null or tap.id = cast(:tamTypeId AS
bigint))", nativeQuery = true)
Optional<List<TamMain>>
getTamMainByOccupationName(@Param("occupationName") String occupationName,
@Param("tamTypeId") Long tamTypeId);
My JPQL (same as query):
@Query("Select t from TamMain t WHERE (:occupationName is null or
(lower(t.tamOccupation.name) like ('%' || lower(:occupationName) || '%')))
AND (:tamTypeId is null or t.tamType.id = :tamTypeId) ")
My Opinion:
Hello ! My ass is burning with such spicy error. It's taking 2days from my
precious life to solve this issue. Tried in so many ways to solve but
couldn't do that. Oh ! Experienced some paranormal activity likewise, "Woow
! It's working now". [A few hours later] "Shit, Its not working !" Although
I didn't change a bit of that code. Now, would you please provide me a
solution of this?
If I provide occupationName in requestParam it gives me error.
If I give null of both of them it gives me same error.
If I give value for tamTypeId then only I get the data.
Have a wonderful day !
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, tareque.bracu@gmail.com
Subject: Re: BUG #17427: ERROR: cannot cast type bytea to bigint
In-Reply-To: <17427-e6d4cf0807ba4424@postgresql.org>
* 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