This is an automated email from the git hooks/post-receive script. New commit to branch feature/jooq in repository wao. See https://gitlab.nuiton.org/None/wao.git commit c513da535af3f0833366fcdc9c621f4912dfd521 Author: Brendan Le Ny <bleny@codelutin.com> Date: Thu Mar 24 18:26:24 2016 +0100 POC --- wao-persistence-jooq/src/test/java/JooqTest.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/wao-persistence-jooq/src/test/java/JooqTest.java b/wao-persistence-jooq/src/test/java/JooqTest.java index 2d4d081..6066c50 100644 --- a/wao-persistence-jooq/src/test/java/JooqTest.java +++ b/wao-persistence-jooq/src/test/java/JooqTest.java @@ -1,14 +1,17 @@ import fr.ifremer.wao.entity.Tables; import org.jooq.DSLContext; import org.jooq.Record; +import org.jooq.Record2; import org.jooq.Result; import org.jooq.SQLDialect; +import org.jooq.SelectSeekStep1; import org.jooq.impl.DSL; import org.junit.Test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import java.sql.Timestamp; public class JooqTest { @@ -24,10 +27,22 @@ public class JooqTest { try (Connection conn = DriverManager.getConnection(url, userName, password)) { DSLContext create = DSL.using(conn, SQLDialect.POSTGRES_9_4); Result<Record> result = create.select().from(Tables.SAMPLEROW).fetch(); - for (Record record : result) { - System.out.println(record); - } + Timestamp oneYearAgo = Timestamp.valueOf("2015-03-15 10:00:00"); + + SelectSeekStep1<Record2<String, String>, Timestamp> query = create + .select(Tables.CONTACT.BOAT, Tables.CONTACT.COMMENT) + .from(Tables.CONTACT.join(Tables.SAMPLEROW).onKey(Tables.CONTACT.SAMPLEROW)) + .where(Tables.SAMPLEROW.OBSPROGRAM.eq("OBSMER")) + .and(Tables.CONTACT.OBSERVATIONBEGINDATE.greaterOrEqual(oneYearAgo)) + .and(Tables.CONTACT.MAMMALSCAPTURE.isTrue()) + .orderBy(Tables.CONTACT.OBSERVATIONBEGINDATE); + Result<Record2<String, String>> result2 = query.fetch(); + for (Record2<String, String> record2 : result2) { + String boatId = record2.getValue(record2.field1()); + String comment = record2.getValue(record2.field2()); + System.out.println(boatId + ", " + comment); + } } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.