JOOQ选择与地图类型值

发布于 2025-01-25 19:53:29 字数 488 浏览 2 评论 0原文

有一个具有MAP类型列的表,地图列类型将如下所示

Map<String, CustomClass.class>

,CustomClass如下所示,

Class CustomClass {
   String name;
   String attr;
}

我想在Map列的值中选择匹配“关键字”包含的记录(无论键是什么键)。我需要下面的东西。有什么办法可以使用?

JooqQuery jooqQuery = (SelectJoinStep<?> step) -> {
  
    step.where(MANAGERS.NAME_DESC_I18N_MAP.contains(
          Map<"ANY KEY", keyword in CustomClass.name> // need help here
      ));

There is a table that has map type column, and the map column type would be like below

Map<String, CustomClass.class>

and CustomClass is like below

Class CustomClass {
   String name;
   String attr;
}

I would like to select record that match 'keyword' contain in map column's values (no matter what key is). I need something like below. Is there any way that I can use?

JooqQuery jooqQuery = (SelectJoinStep<?> step) -> {
  
    step.where(MANAGERS.NAME_DESC_I18N_MAP.contains(
          Map<"ANY KEY", keyword in CustomClass.name> // need help here
      ));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你又不是我 2025-02-01 19:53:29

您可以使用喜欢作为量化的比较谓词在Jooq中。如果您的RDBMS不在本地支持,JOOQ将为您效仿。尝试以下操作:

MANAGERS.NAME_DESC_I18N_MAP.like(any(
    map.values().stream().map(cc -> "%" + cc.name + "%").toArray(String[]::new)
))

您无法以这种方式使用contains(),但是我想没关系。

另请参阅此博客文章有关使用 喜欢作为量化的比较谓词

You can use LIKE as a quantified comparison predicate in jOOQ. If it's not supported natively by your RDBMS, jOOQ will emulate it for you. Try this:

MANAGERS.NAME_DESC_I18N_MAP.like(any(
    map.values().stream().map(cc -> "%" + cc.name + "%").toArray(String[]::new)
))

You can't use contains() in this way yet, but I guess that's OK.

See also this blog post about using LIKE as a quantified comparison predicate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文