【问题标题】:Spring data jpa Query dynamically pass where clauseSpring data jpa Query动态传递where子句
【发布时间】:2016-11-26 08:10:34
【问题描述】:

我的实体是这样的

public class event
    {
        String title;

        String description;

        String city;
    }

我是 Spring data jpa 的新手,我想在用户输入“Hello Hyderabad Fest”时实现搜索功能 我希望标记大小的字符串并拆分为单词,并在搜索查询命中 db 的实体上的任何属性上找到任何单词匹配。

WHERE title LIKE '%Hello%' OR title LIKE '%Hyderabad%' OR title LIKE '%Fest%' OR description LIKE '%Hello%' OR description LIKE '%Hyderabad%' OR 描述 LIKE '%Fest%'city LIKE '%Hello%' OR cityitle LIKE '%Hyderabad%' OR city LIKE '%Fest%'

我们如何在 spring data jpa 中实现这一点。

  1. 我们能否在 Spring data jpa 命名查询中动态传递 where 条件
  2. 我们可以在 nosql dbs 中使用 lucene 类型的查询吗?
  3. 任何其他建议

提前致谢。

【问题讨论】:

标签: spring postgresql hibernate lucene spring-data-jpa


【解决方案1】:

Postgresql全文搜索查询解决了上述问题http://rachbelaid.com/postgres-full-text-search-is-good-enough/

【讨论】:

    猜你喜欢
    • 2015-09-20
    • 2020-06-19
    • 2019-11-13
    • 2017-01-18
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 2016-04-29
    • 1970-01-01
    相关资源
    最近更新 更多