当结果记录具有具有相同名称的两个不同表的两个列时,如何在Jooq中的名称中选择列?
我正在使用JOOQ,并且由于与某些加入的查询有关,我有一个记录。
该记录包括两个带有名称“ ID”的列,我需要选择其中一个。
this 具有字符串为参数,并且传递“ ID”(可能返回第一次出现)时不会失败。
我看到的另一种选择是使用方法接收带有索引的INT。这可以正常工作,但我希望避免它。
I am using Jooq and as a result of a query with some joins I have a list of Record .
This record includes two columns with name "id" and I would need to select one of them.
This method has String as parameter and it is not failing when passing "id" (probably returning the first occurrence).
The other alternative I saw is to use the method that receives an int with the index. This would work ok but I would prefer to avoid it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这种情况下发现的最好的替代方法是使用 method 接收 field 作为参数。
通过使用字段,我们可以指定表和列名称,以便我们确定我们选择了所需的列。
因此,基本上,如果我们在查询结果上都有“ ID”列的表A和B,我们可以定义一个字段
,然后在处理结果时,我们可以通过
The best alternative I found on this case is to use the method that receives Field as parameter.
By using Field we can specify the table and column name so we are sure that we are selecting the column that we want.
So basically if we have table A and B both with "id" columns on the result of the query we can just define a field
And then when processing the results we can access it by