在Jooq中提取子句

发布于 2025-02-04 23:20:07 字数 342 浏览 1 评论 0 原文

我正在尝试从表中获取值Legal_entity_id(Integer),以便以后使用。

 public static int fetchingLegalEntityId() {
    return DSL.using(connection).select(LEGAL_ENTITIES.LEGAL_ENTITY_ID)
            .from(LEGAL_ENTITIES)
            .where(LEGAL_ENTITIES.CODE.eq("someValue"))
            .fetchOne();      
}

但是我有不兼容的类型。 我需要做什么?

I'm trying to get value LEGAL_ENTITY_ID (Integer) from table for to use later.

 public static int fetchingLegalEntityId() {
    return DSL.using(connection).select(LEGAL_ENTITIES.LEGAL_ENTITY_ID)
            .from(LEGAL_ENTITIES)
            .where(LEGAL_ENTITIES.CODE.eq("someValue"))
            .fetchOne();      
}

but I have incompatible types.
What I need to do?

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

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

发布评论

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

评论(1

只等公子 2025-02-11 23:20:07

产生记录有很多方法可以在许多方法中获取数据jooq

我可以推荐各种选项,包括:

  • fetchoptional()。映射(record :: value1).orelsethrow(...)
  • fetchone(lage_entities.legal_entity_id)
  • dslContext 。

​只需探索JOOQ API(例如,使用IDE并自动完成您的 fetch()调用以查看可用的内容),然后选择您喜欢的样式。

ResultQuery.fetchOne() produces a Record. There are many many ways to fetch data in jOOQ.

I could recommend various options, including:

  • fetchOptional().map(Record::value1).orElseThrow(...)
  • fetchOne(LEGAL_ENTITIES.LEGAL_ENTITY_ID)
  • DSLContext.fetchValue(select)
  • And many more

There isn't a best way to do such a query. Just explore the jOOQ API (e.g. by using an IDE and auto-completing your fetch() call to see what's available), and pick the style you prefer.

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