【问题标题】:How to run native postgres query using spring-data-jpa如何使用 spring-data-jpa 运行本机 postgres 查询
【发布时间】:2019-06-21 21:38:07
【问题描述】:

我正在使用 spring-data-jpa 运行本机 postgres 查询。查询是在实体的 jsonb 数据上执行的。 我可以在数据库服务器上成功运行原始查询:

SELECT e.* 
FROM public.entity e where e.json ? 'salary' and e.json ->> 'salary' > '10000';

但是,由于spring-data-jpa 也支持? 进行参数化查询,所以查询的语法似乎存在冲突,因此应用程序最终甚至无法启动。

@Query(value = "select e.* from Entity e where e.json ? 'salary' and e.json->> 'salary' > ?1", nativeQuery = true)
List<Lead> getEntitiesBySalaryGreaterThan(String value);

}

请告诉我在spring-data-jpa env 中执行预期本机查询的解决方法或正确方法

【问题讨论】:

    标签: postgresql spring-data-jpa


    【解决方案1】:

    您是否可能需要按照here 的描述转义?

    【讨论】:

    • 我已经有了,如果你看到你的 @query 它有两个 nativeQuery
    • 谢谢哥们!!不知道 postgres 允许创建自定义操作符
    猜你喜欢
    • 2019-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    • 2020-06-25
    • 2021-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多