BUG #17427: ERROR: cannot cast type bytea to bigint

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: tareque(dot)bracu(at)gmail(dot)com
Subject: BUG #17427: ERROR: cannot cast type bytea to bigint
Date: 2022-03-06 06:29:45
Message-ID: 17427-e6d4cf0807ba4424@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17427
Logged by: Ahmed Tareque
Email address: tareque(dot)bracu(at)gmail(dot)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 !

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Julien Rouhaud 2022-03-06 07:41:34 Re: BUG #17393: Delete database after recovery with point-in-time is still missing datafiles
Previous Message Tom Lane 2022-03-05 15:19:02 Re: BUG #17421: Core dump in ECPGdo() when calling PostgreSQL API from 32-bit client for RHEL8