小编ray*_*-ag的帖子

在 JPA 命名查询中使用 postgres 函数“lower”时出错

知道为什么 hibernate 会抱怨类型转换吗?我已经将字符串作为字符串传递给函数。我正在使用带有命名参数的 @Query 语法。在查询中嵌入较低的函数可以吗?

源代码:

@Query("from UserEntity t where lower(t.email) = lower(:email)")
List<UserEntity> findByEmail(@Param("email") String email);
Run Code Online (Sandbox Code Playgroud)

错误:

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
Run Code Online (Sandbox Code Playgroud)

相关链接:https : //docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.named-parameters

java postgresql hibernate spring-data-jpa

6
推荐指数
1
解决办法
6914
查看次数

标签 统计

hibernate ×1

java ×1

postgresql ×1

spring-data-jpa ×1