How to use alias in jOOQ

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

Could someone please guide me on how to use alias in jOOQ. I tried looking into jOOQ documentation but it is not clear. Please provide an example if possible.

回答1:

Both org.jooq.Table and org.jooq.Field types implement org.jooq.AliasProvider. This means, that you can call as(String) on them, to create an aliased object. Example:

Table<?> aliasedTable = MY_TABLE.as("t"); Field<?> aliasedField = MY_FIELD.as("f"); 

The examples from the jOOQ manual include:

TBook book = T_BOOK.as("b"); TAuthor author = T_AUTHOR.as("a");  create.select(author.ID, book.ID)       .from(author)       .join(book).on(author.ID.equal(book.AUTHOR_ID)) 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!