![](/img/trans.png)
[英]JOOQ Howto fetch a result of join into POJO without flattening properties?
[英]JOOQ - Fetch into custom POJO that does not have all properties
假設我有一個包含許多字段的結果集,包括 id、first_name、last_name、age 等。
是否可以制作一個只包含我關心的特定字段並獲取其中的自定義 POJO(不更改 select / 指定每一列),或者手動映射它們,所以我最終會得到類似的結果:
class User {
public long id;
public String name;
}
dslContext.select().<some conditions>.fetchInto(User) // or something other than fetchInto
這只是一個例子,真實的東西會有很多字段,所以我寧願不手動做。 不確定這是否可能,但我想我應該問。
是的,這是可能的。
jOOQ 會將 map 的結果提供給您的用戶 class。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.