【问题标题】:How to use FIND_IN_SET in jpa如何在 jpa 中使用 FIND_IN_SET
【发布时间】:2018-07-19 11:26:14
【问题描述】:

如何在 jpa 中使用find_in_set

我需要这样实现
SQL - select * from teacher where find_in_set("5", deptIds) and id = 101

deptIds 有逗号分隔的 ID(我知道这是个坏主意,但很旧。)

为此,我曾尝试使用Criteria,但没有找到任何可以满足find_in_setRestrictions
注意 - 需要Criteria 和@987654328 的可能解决方案@

【问题讨论】:

    标签: java hibernate jpa-2.0 find-in-set


    【解决方案1】:
    criteriaBuilder.function("find_in_set", Boolean.class,
            criteriaBuilder.literal(s),
            root.get("field"))
    

    【讨论】:

      【解决方案2】:
      select t from Teacher t where find_in_set("5", t.deptIds) = 0 and t.id = 101
      

      【讨论】:

        猜你喜欢
        • 2019-05-20
        • 2017-08-25
        • 2017-11-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多