简体   繁体   English

如何在列表中获取jooq记录

[英]How to get jooq record on list

I have a method我有一个方法

private List<User> selectUser() {
    return dslContext
        .select(USER_ACCOUNT.asterisk())
        .from(USER_ACCOUNT)
        .fetch(recordMapper);
}

How do I get the data into the list?如何将数据放入列表中?

public User getUser(String userId) {
    return selectUser()
            .where(USER_ACCOUNT.USER_ACCOUNT_ID.eq(userId))
            .fetchOne(recordMapper);
}

I'm assuming you want to read UserAccountRecord instead of User POJO values?我假设您想读取UserAccountRecord而不是User POJO 值? Then just use DSLContext.selectFrom() .然后只需使用DSLContext.selectFrom() Eg例如

private List<UserAccountRecord > selectUser() {
    return dslContext
        .selectFrom(USER_ACCOUNT)
        .fetch();
}

public UserAccountRecord getUser(String userId) {
    return selectFrom(USER_ACCOUNT)
            .where(USER_ACCOUNT.USER_ACCOUNT_ID.eq(userId))
            .fetchOne();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM