import static org.jooq.example.db.h2.generated.Tables.*; try (Connection conn = DriverManager.getConnection("jdbc:h2:~/test")) { DSLContext context = DSL.using(conn, SQLDialect.H2); Result<Record> result = context.select() .from(AUTHOR) .join(BOOK).on(AUTHOR.ID.eq(BOOK.AUTHOR_ID)) .where(BOOK.PUBLISHED.isTrue()) .orderBy(AUTHOR.ID.desc()) .fetch(); for (Record record : result) { Integer id = record.getValue(AUTHOR.ID); String firstName = record.getValue(AUTHOR.FIRST_NAME); String lastName = record.getValue(AUTHOR.LAST_NAME); System.out.println("Author: " + id + " " + firstName + " " + lastName); } } catch (SQLException e) { e.printStackTrace(); }


上一篇:
下一篇:
切换中文