我正在从javax迁移到jakkind. 我们的项目是用Spring Boot(从2.7升级到3.2)和Hibernate(5.6到6.3)构建的,我们使用PostgreSQL数据库(V14).一个trap 是自定义PostgreSQL方言的迁移,但我想我解决了令人满意的问题
当我们执行查询时,会出现主要问题:
SELECT o FROM Order o WHERE (o.createdAt between :from and :to) AND (:query is null OR function('pgTextSearch', :query, o) = true) AND (:createdBy is null OR LOWER(o.createdBy) = LOWER(:createdBy))
它说:
Caused by: org.postgresql.util.PSQLException: ERROR: function lower(bytea) does not exist
Hinweis: No function matches the given name and argument types. You might need to add explicit type casts.
据我所知,这来自以‘NULL’作为参数的LOWER()函数的调用.:createdBy声明为字符串(分别为Varchar).在我的场景中:createdBy为空,但这应该被第一个OR条件截取.我遗漏了什么?
此外,我通过PostgreSQL-CLI执行了带有替换参数的查询,没有出现任何问题.
P.S. The query was modified for migration, but only within the custom function part.
P.P.S. I read the migration guides for spring boot and hibernate (SQM yikes!), but could not find any overlap to my use case.
P.P.P.S. I'm not setting the parameter by hand (e.g. .setParameter("createdBy", xyz)), the repository is a JpaRepository, thus parameter replacement is done by Spring Data