Any idea why hibernate is complaining about the typecasting? I am already passing in as a String to the function. I am using @Query syntax with named parameters. Is it okay to have lower function embedded inside the query?
Source Code:
@Query("from UserEntity t where lower(t.email) = lower(:email)")
List<UserEntity> findByEmail(@Param("email") String email);
Error:
Caused by: org.postgresql.util.PSQLException: ERROR: function lower(bytea) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 899
nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Related Link: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.named-parameters
I finally understood what is happening. I was getting the error because when I called the function findByEmail
, in some cases email was null
which is causing the postgres to complain. I just needed to check for null
before call this function. Thanks @akshar-patel for trying to help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With