JOOQ:使用字符串获取表和列?

编程入门 行业动态 更新时间:2024-10-15 22:29:54
本文介绍了JOOQ:使用字符串获取表和列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好,我在Spring Boot中使用JOOQ,想知道是否有一种方法可以获取具有其名称字符串的表及其列?例如:

Hello I'm using JOOQ with Spring Boot and was wondering if there was a way to obtain a table and its columns with a string of their name? For example:

我希望能够通过执行以下操作来获取表格:

I want to be able to get a table by doing something like:

someObject.getTable("user")

然后使用该get方法的结果,我还想获取该表的所有列,并能够将列名与其他字符串进行比较.换句话说,如果有一种获取表的方法,我还可以从同一对象中获取表的列名吗?

Then using the result of that get method I also want to obtain all of that table's columns and be able to compare the column names to other strings. In other words if there is a way to get a table, can I also get the table's column names from that same object?

在此方面,我将不胜感激.

I would really appreciate any help with this.

推荐答案

是的,您可以:

当您生成模式时,所有这些信息都可以从生成的代码中获得.只需转到您的架构并查找表(区分大小写!):

When you generate your schema, all this information is available to you from generated code. Just go to your schema and look for the table (case-sensitive!):

Table<?> table = PUBLIC.getTable("user");

然后:

Field<?>[] fields = table.fields();

使用 org.jooq.Meta

如果尚未生成元数据,您仍然可以使用 DSLContext.meta() ,从中可以浏览架构/表/等.

Using org.jooq.Meta

If you don't have generated meta data, you can still look up things from your JDBC connection using DSLContext.meta(), from where you can navigate your schemas / tables / etc.

更多推荐

JOOQ:使用字符串获取表和列?

本文发布于:2023-10-28 03:54:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535439.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   JOOQ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!