From 7d420d8152dacc33b1fe2ae1620ab556ea45431d Mon Sep 17 00:00:00 2001 From: lukaseder Date: Fri, 23 Dec 2016 16:35:42 +0100 Subject: [PATCH] Release 3.9.0 --- .../resources/org/jooq/web/manual-3.9.xml | 262 ++++++++++++++++-- 1 file changed, 244 insertions(+), 18 deletions(-) diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml index 92572e9e75..3394af7c73 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.9.xml @@ -4719,7 +4719,7 @@ SELECT * FROM BOOK LIMIT 1 OFFSET 2 -- CUBRID supports a MySQL variant of the LIMIT .. OFFSET clause SELECT * FROM BOOK LIMIT 2, 1 --- Derby, SQL Server 2012, Oracle 12c (syntax not yet supported by jOOQ), the SQL:2008 standard +-- Derby, SQL Server 2012, Oracle 12c, the SQL:2008 standard SELECT * FROM BOOK OFFSET 2 ROWS FETCH NEXT 1 ROWS ONLY -- Informix has SKIP .. FIRST support @@ -5665,18 +5665,27 @@ VALUES ('John', 'Hitchcock')

Indexes

+create.alterIndex("old_index").renameTo("new_index").execute(); + +// Renaming the index only if it exists (not all databases support this) +create.alterIndexIfExists("old_index").renameTo("new_index").execute();]]>

Schemas

+create.alterSchema("old_schema").renameTo("new_schema").execute(); + +// Renaming the schema only if it exists (not all databases support this) +create.alterSchemaIfExists("old_schema").renameTo("new_schema").execute();]]>

Sequences

@@ -5688,7 +5697,10 @@ create.alterSequence(S_AUTHOR_ID).restartWith(n).execute();]]>

+create.alterTable("old_table").renameTo("new_table").execute(); + +// Renaming the table only if it exists (not all databases support this) +create.alterTableIfExists("old_table").renameTo("new_table").execute();]]>

These statements alter / add / drop columns and their types: @@ -5731,7 +5743,10 @@ create.alterTable(AUTHOR).dropConstraint("UK_TITLE").execute();]]>

Views

+create.alterView("old_view").renameTo("new_view").execute(); + +// Renaming the view only if it exists (not all databases support this) +create.alterViewIfExists("old_view").renameTo("new_view").execute();]]> @@ -5749,20 +5764,30 @@ create.alterView("old_view").renameTo("new_view").execute();]]>

Schemas

+create.createSchema("new_schema").execute(); + +// Create a schema only if it doesn't exists (not all databases support this) +create.createSchemaIfNotExists("new_schema").execute();]]>

Sequences

- - - - +

Tables

@@ -5786,11 +5811,16 @@ create.createTable("TOP_AUTHORS").as( .where(val(50).lt( selectCount().from(BOOK) .where(BOOK.AUTHOR_ID.eq(AUTHOR.ID)) - ))).execute();]]> + ))).execute(); + +// Create a table only if it doesn't exists (not all databases support this) +create.createTableIfNotExists("TOP_AUTHORS") + ...]]>

Views

- + ))).execute(); + +// Create a view only if it doesn't exists (not all databases support this) +create.createTableIfNotExists("TOP_AUTHORS") + ...]]> @@ -5813,23 +5847,43 @@ create.createTable("TOP_AUTHORS").as(

Indexes

- +

Schemas

- +

Sequences

- +

Tables

- +

Views

- + @@ -9667,6 +9721,36 @@ public class BindValueAbbreviator extends DefaultVisitListener { +
+ SQL Parser + +

+ jOOQ includes a SQL parser API (EXPERIMENTAL in jOOQ 3.9), which allows for parsing a SQL String into a of a specified type, including: +

+ +
    +
  • A set of
  • +
  • A single
  • +
  • A
  • +
  • A
  • +
  • A
  • +
+ +

+ The current implementation of the parser is dialect agnostic and will try to parse any SQL dialect into a standard jOOQ expression tree, for instance: +

+ + + +

+ The value of such an API becomes immediately clear as the parser can consume any type of SQL string (as long as it can be represented using jOOQ API) and the generated expression tree can then be serialised again in any possible way. This can be very helpful when migrating from one database dialect to another, even without really using jOOQ as a database abstraction layer. +

+
+
+
SQL building in Scala @@ -13433,6 +13517,11 @@ result.forEach((Object[] entities) -> { Synthetic primary keys will override existing primary keys. --> SCHEMA\.TABLE\.COLUMN(1|2) + + SCHEMA\.TABLE\.COLUMN + + + org.jooq + jooq-checker + {jooq-version} +]]> + +

+ ... you can now include one of the two checkers: +

+ +

SQLDialectChecker

+ +

+ The SQLDialect checker reads all of the and annotations in your source code and checks if the jOOQ API you're using is allowed and/or required in a given context, where that context can be any scope, including: +

+ +
    +
  • A package
  • +
  • A class
  • +
  • A method
  • +
+ +

+ Configure this compiler plugin: +

+ + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + true + + org.jooq.checker.SQLDialectChecker + + + -Xbootclasspath/p:1.8 + + +]]> + +

+ ... annotate your packages, e.g. +

+ +// Scope: entire package (put in package-info.java) +@Allow(ORACLE) +package org.jooq.example.checker; + +

+ And now, you'll no longer be able to use any SQL Server specific functionality that is not available in Oracle, for instance. Perfect! +

+ +

+ There are quite some delicate rules that play into this when you nest these annotations. Please refer to this blog post for details. +

+ +

PlainSQLChecker

+ +

+ This checker is much simpler. Just add the following compiler plugin to deactivate plain SQL usage by default: +

+ + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + true + + org.jooq.checker.PlainSQLChecker + + + -Xbootclasspath/p:1.8 + + +]]> + +

+ From now on, you won't risk any SQL injection in your jOOQ code anymore, because your compiler will reject all such API usage. If, however, you need to place an exception on a given package / class / method, simply add the annotation, as such: +

+ + iKnowWhatImDoing() { + return DSL.using(configuration) + .select(level()) + .connectBy("level < ?", bindValue) + .fetch(0, int.class); +}]]> + +

+ The checker framework does add some significant overhead in terms of compilation speed, and its IDE tooling is not yet at a level where such checks can be fed into IDEs for real user feedback, but the framework does work pretty well if you integrate it in your CI, nightly builds, etc. +

+
+
+
SQL 2 jOOQ Parser