ChunfyTseng
ChunfyTseng

Reputation: 111

Jooq how to query entity based on composite key

How to query an entity based on a composite key in Jooq? E.g.:

UserAttempts org.jooq.impl.DAOImpl.findById(Record2<UInteger, String> id)

id is a composite key. How to use the Record2<UInteger, String>?

Upvotes: 5

Views: 1871

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 221145

You can construct a Record2 using DSLContext.newRecord():

UserAttempts attempts =
dao.findById(ctx.newRecord(USER_ATTEMPTS.ID_COLUMN1, USER_ATTEMPTS.ID_COLUMN2)
                .values(uint(1), "abc"));

Upvotes: 8

Related Questions