diff --git a/.travis.yml b/.travis.yml index 32027ddc2d..f4d860e802 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,13 @@ jdk: install: - sh -c 'mvn install -DskipTests=true' - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-examples/jOOQ-spring-example && mvn install -DskipTests=true' || echo "Skipping for JDK6 and 7" + - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-examples/jOOQ-flyway-example && mvn install -DskipTests=true' || echo "Skipping for JDK6 and 7" - sh -c 'cd jOOQ-examples/jOOQ-spring-guice-example && mvn install -DskipTests=true' - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-test-utils && mvn install -DskipTest=true' || echo "Skipping for JDK6 and 7" - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-test && mvn install -DskipTests=true' || echo "Skipping for JDK6 and 7" script: - sh -c 'mvn test' - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-examples/jOOQ-spring-example && mvn test' || echo "Skipping for JDK6 and 7" + - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-examples/jOOQ-flyway-example && mvn test' || echo "Skipping for JDK6 and 7" - sh -c 'cd jOOQ-examples/jOOQ-spring-guice-example && mvn test' - sh -c 'echo $JAVA_HOME | grep -q 8 && cd jOOQ-test && mvn test -Dorg.jooq.test-dialects=h2 -Dorg.jooq.test.pretty-printer=false -Dlog4j.configuration=log4j-quiet.xml' || echo "Skipping for JDK6 and 7" diff --git a/jOOQ-examples/jOOQ-flyway-example/README.md b/jOOQ-examples/jOOQ-flyway-example/README.md index 35cffc8d64..566965d4ef 100644 --- a/jOOQ-examples/jOOQ-flyway-example/README.md +++ b/jOOQ-examples/jOOQ-flyway-example/README.md @@ -1,9 +1,6 @@ Thanks for downloading jOOQ. Please visit http://www.jooq.org for more information. -This example was inspired by Petri Kainulainen's excellent blog post: -http://www.petrikainulainen.net/programming/jooq/using-jooq-with-spring-configuration/ - To install and run this example, please check out the complete jOOQ repository first, and use Maven to install the latest SNAPSHOT version of jOOQ: ``` @@ -13,7 +10,7 @@ $ ls jOOQ jOOQ-meta jOOQ-codegen ... $ mvn clean install ... -$ cd jOOQ-examples/jOOQ-spring-example +$ cd jOOQ-examples/jOOQ-flyway-example ... $ mvn clean install ``` diff --git a/jOOQ-examples/jOOQ-flyway-example/pom.xml b/jOOQ-examples/jOOQ-flyway-example/pom.xml index 1c2488adff..566e705816 100644 --- a/jOOQ-examples/jOOQ-flyway-example/pom.xml +++ b/jOOQ-examples/jOOQ-flyway-example/pom.xml @@ -62,6 +62,22 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + true + 1024m + 256m + UTF-8 + 1.7 + 1.7 + true + lines,vars,source + + + org.flywaydb flyway-maven-plugin @@ -94,24 +110,25 @@ generate - - - ${db.url} - ${db.username} - - - - .* - FLYWAY_TEST - - - org.jooq.example.flyway.db.h2 - target/generated-sources/jooq-h2 - - - + + + + ${db.url} + ${db.username} + + + + .* + FLYWAY_TEST + + + org.jooq.example.flyway.db.h2 + target/generated-sources/jooq-h2 + + + diff --git a/jOOQ-examples/jOOQ-flyway-example/src/main/resources/db/migration/V3__create_book_table_and_add_records.sql b/jOOQ-examples/jOOQ-flyway-example/src/main/resources/db/migration/V3__create_book_table_and_add_records.sql index 456651fe4e..9a1f1136aa 100644 --- a/jOOQ-examples/jOOQ-flyway-example/src/main/resources/db/migration/V3__create_book_table_and_add_records.sql +++ b/jOOQ-examples/jOOQ-flyway-example/src/main/resources/db/migration/V3__create_book_table_and_add_records.sql @@ -1,27 +1,17 @@ CREATE TABLE flyway_test.book ( id INT NOT NULL, author_id INT NOT NULL, - co_author_id INT, - details_id INT, title VARCHAR(400) NOT NULL, - published_in INT, - language_id INT, - content_text CLOB, - content_pdf BLOB, - - rec_version INT, - rec_timestamp TIMESTAMP, CONSTRAINT pk_t_book PRIMARY KEY (id), - CONSTRAINT fk_t_book_author_id FOREIGN KEY (author_id) REFERENCES flyway_test.author(id), - CONSTRAINT fk_t_book_co_author_id FOREIGN KEY (co_author_id) REFERENCES flyway_test.author(id) + CONSTRAINT fk_t_book_author_id FOREIGN KEY (author_id) REFERENCES flyway_test.author(id) ); INSERT INTO flyway_test.author VALUES (next value for flyway_test.s_author_id, 'George', 'Orwell', '1903-06-25', 1903, null); INSERT INTO flyway_test.author VALUES (next value for flyway_test.s_author_id, 'Paulo', 'Coelho', '1947-08-24', 1947, null); -INSERT INTO flyway_test.book VALUES (1, 1, null, null, '1984', 1948, 1, 'To know and not to know, to be conscious of complete truthfulness while telling carefully constructed lies, to hold simultaneously two opinions which cancelled out, knowing them to be contradictory and believing in both of them, to use logic against logic, to repudiate morality while laying claim to it, to believe that democracy was impossible and that the Party was the guardian of democracy, to forget, whatever it was necessary to forget, then to draw it back into memory again at the moment when it was needed, and then promptly to forget it again, and above all, to apply the same process to the process itself -- that was the ultimate subtlety; consciously to induce unconsciousness, and then, once again, to become unconscious of the act of hypnosis you had just performed. Even to understand the word ''doublethink'' involved the use of doublethink..', null, 1, '2010-01-01 00:00:00'); -INSERT INTO flyway_test.book VALUES (2, 1, null, null, 'Animal Farm', 1945, 1, null, null, null, '2010-01-01 00:00:00'); -INSERT INTO flyway_test.book VALUES (3, 2, null, null, 'O Alquimista', 1988, 4, null, null, 1, null); -INSERT INTO flyway_test.book VALUES (4, 2, null, null, 'Brida', 1990, 2, null, null, null, null); +INSERT INTO flyway_test.book VALUES (1, 1, '1984'); +INSERT INTO flyway_test.book VALUES (2, 1, 'Animal Farm'); +INSERT INTO flyway_test.book VALUES (3, 2, 'O Alquimista'); +INSERT INTO flyway_test.book VALUES (4, 2, 'Brida'); \ No newline at end of file diff --git a/jOOQ-examples/jOOQ-flyway-example/src/test/java/AfterMigrationTest.java b/jOOQ-examples/jOOQ-flyway-example/src/test/java/AfterMigrationTest.java index d4b0dda277..c97fc344b2 100644 --- a/jOOQ-examples/jOOQ-flyway-example/src/test/java/AfterMigrationTest.java +++ b/jOOQ-examples/jOOQ-flyway-example/src/test/java/AfterMigrationTest.java @@ -2,6 +2,9 @@ import org.jooq.Result; import org.jooq.impl.DSL; import org.junit.Test; +import java.sql.Connection; +import java.sql.DriverManager; + import static java.util.Arrays.asList; import static org.jooq.example.flyway.db.h2.Tables.*; import static org.junit.Assert.assertEquals; @@ -12,22 +15,24 @@ import static org.junit.Assert.assertEquals; public class AfterMigrationTest { @Test - public void testQueryingAfterMigration() { - Result result = - DSL.using("jdbc:h2:~/flyway-test", "sa", "") - .select( - AUTHOR.FIRST_NAME, - AUTHOR.LAST_NAME, - BOOK.ID, - BOOK.TITLE - ) - .from(AUTHOR) - .join(BOOK) - .on(AUTHOR.ID.eq(BOOK.AUTHOR_ID)) - .orderBy(BOOK.ID.asc()) - .fetch(); + public void testQueryingAfterMigration() throws Exception { + try (Connection c = DriverManager.getConnection("jdbc:h2:~/flyway-test", "sa", "")) { + Result result = + DSL.using(c) + .select( + AUTHOR.FIRST_NAME, + AUTHOR.LAST_NAME, + BOOK.ID, + BOOK.TITLE + ) + .from(AUTHOR) + .join(BOOK) + .on(AUTHOR.ID.eq(BOOK.AUTHOR_ID)) + .orderBy(BOOK.ID.asc()) + .fetch(); - assertEquals(4, result.size()); - assertEquals(asList(1, 2, 3, 4), result.getValues(BOOK.ID)); + assertEquals(4, result.size()); + assertEquals(asList(1, 2, 3, 4), result.getValues(BOOK.ID)); + } } }