ray*_*-ag 6 java postgresql hibernate spring-data-jpa
知道为什么 hibernate 会抱怨类型转换吗?我已经将字符串作为字符串传递给函数。我正在使用带有命名参数的 @Query 语法。在查询中嵌入较低的函数可以吗?
源代码:
@Query("from UserEntity t where lower(t.email) = lower(:email)")
List<UserEntity> findByEmail(@Param("email") String email);
错误:
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
相关链接:https : //docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.named-parameters
ray*_*-ag 11
我终于明白是怎么回事了。我收到错误是因为当我调用函数时findByEmail,在某些情况下是电子邮件null导致 postgres 抱怨。我只需要null在调用这个函数之前检查一下。感谢 @akshar-patel 尝试提供帮助。
| 归档时间: | 
 | 
| 查看次数: | 6914 次 | 
| 最近记录: |