首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法转换ltree JPARepository

无法转换ltree JPARepository
EN

Stack Overflow用户
提问于 2020-06-23 00:31:49
回答 1查看 29关注 0票数 0

原生查询:

代码语言:javascript
复制
1. SELECT * from test where path <@ 'a.b.c' and path <> 'a.b.c';
2. SELECT * FROM test WHERE path ~ '*.b.c.*{1}'

JPA:

代码语言:javascript
复制
@Query(value = "select * from test where path <@ 'a.b.c' and path <> 'a.b.c'", nativeQuery = true)
List<Test> getAllPath(@Param("pathToSearch") String pathToSearch);

我想用pathToSearch param代替a.b.c

错误:

代码语言:javascript
复制
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: ltree <@ character varying
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
EN

回答 1

Stack Overflow用户

发布于 2020-06-23 02:12:35

它起作用了

代码语言:javascript
复制
@Query(value = "SELECT * FROM test WHERE path <@ CAST(:pathToSearch AS ltree) and path <> CAST(:pathToSearch AS ltree)", nativeQuery = true)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62525527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档