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 !