From 5d6eea5bde689e7f22c191476a61afd1c8bf535c Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Sun, 18 Sep 2011 14:36:40 +0000 Subject: [PATCH] Added some sections to the manual --- jOOQ-website/css/jooq.css | 19 ++++++ jOOQ-website/frame.php | 8 ++- jOOQ-website/manual/DSL/index.php | 52 +++++++++++++- jOOQ-website/manual/META/SEQUENCE/index.php | 37 +++++++++- jOOQ-website/src/main/resources/manual.xml | 75 +++++++++++++++++++++ 5 files changed, 185 insertions(+), 6 deletions(-) diff --git a/jOOQ-website/css/jooq.css b/jOOQ-website/css/jooq.css index 92cab93cb8..8aad0c307f 100644 --- a/jOOQ-website/css/jooq.css +++ b/jOOQ-website/css/jooq.css @@ -183,6 +183,25 @@ div.navigation-item-left { height: 40px; } +#footer { + font-size: 0.7em; + color: #ddd; + + padding-top: 1em; + padding-left: 3em; + padding-right: 3em; + padding-bottom: 1em; + + background: #888787; + background: -webkit-gradient(linear, left bottom, right top, from(#888787), to(#666)); + background: -moz-linear-gradient(left bottom, #888787, #666); + background: gradient(linear, left bottom, right top, from(#888787), to(#666)); + -webkit-box-shadow: inset rgba(0,0,0,.1) 0 5px 5px; + -moz-box-shadow: inset rgba(0,0,0,.1) 0 5px 5px; + box-shadow: inset rgba(0,0,0,.1) 0 5px 5px; + border-top: 1px solid rgba(0,0,0,.2); + text-shadow: #555 -1px -1px 0px;} + div.tweet-item-left { float: left; padding-right: 2em; diff --git a/jOOQ-website/frame.php b/jOOQ-website/frame.php index e09c9193cf..bc247ed8bd 100644 --- a/jOOQ-website/frame.php +++ b/jOOQ-website/frame.php @@ -79,10 +79,14 @@ } printContent(); ?> - -

+ + diff --git a/jOOQ-website/manual/DSL/index.php b/jOOQ-website/manual/DSL/index.php index c06414d328..3e189fcf08 100644 --- a/jOOQ-website/manual/DSL/index.php +++ b/jOOQ-website/manual/DSL/index.php @@ -7,7 +7,8 @@ function printH1() { print "DSL or fluent API. Where SQL meets Java"; } function getSlogan() { - return ""; + return " + "; } function printContent() { global $root; @@ -16,7 +17,54 @@ function printContent() { The jOOQ User Manual : DSL or fluent API. Where SQL meets Javaprevious : next -

Table of contents

    + +

    jOOQ ships with its own DSL (or Domain Specific Language) that + simulates SQL as good as possible in Java. This means, that you can + write SQL statements almost as if Java natively supported that syntax + just like .NET's C# does with LINQ to SQL. +

    + +

    Here is an example to show you what that means. When you want to write a query like this in SQL:

    + + + + + + + + + + + + + + + + +
    Here is an example to show you what that means. When you want to write a query like this in SQL: Then, using jOOQ's DSL API, you can write the same query as such:
    +
    +-- Select all books by authors born after 1920, 
    +-- named "Paulo" from a catalogue:
    +SELECT * 
    +  FROM t_author a 
    +  JOIN t_book b ON a.id = b.author_id 
    + WHERE a.year_of_birth > 1920 
    +   AND a.first_name = 'Paulo'
    + ORDER BY b.title
    +
    +
    +Result<Record> result = 
    +create.select()
    +      .from(T_AUTHOR)
    +      .join(T_BOOK).on(TAuthor.ID.equal(TBook.AUTHOR_ID))
    +      .where(TAuthor.YEAR_OF_BIRTH.greaterThan(1920)
    +      .and(TAuthor.FIRST_NAME.equal("Paulo")))
    +      .orderBy(TBook.TITLE)
    +      .fetch();
    +
    + +

    You couldn't come much closer to SQL itself in Java, without re-writing the compiler.

    +

    Table of contents

    1. Complete SELECT syntax
    2. diff --git a/jOOQ-website/manual/META/SEQUENCE/index.php b/jOOQ-website/manual/META/SEQUENCE/index.php index 5fe074af5c..840d88b83e 100644 --- a/jOOQ-website/manual/META/SEQUENCE/index.php +++ b/jOOQ-website/manual/META/SEQUENCE/index.php @@ -7,7 +7,10 @@ function printH1() { print "Sequences"; } function getSlogan() { - return ""; + return " + jOOQ also generates convenience artefacts for sequences, where this is + supported: DB2, Derby, H2, HSQLDB, Oracle, Postgres, and more. + "; } function printContent() { global $root; @@ -16,7 +19,37 @@ function printContent() { The jOOQ User Manual : Meta model code generation : Sequencesprevious : next -
      +
      +

      Sequences as a source for identity values

      +

      Sequences implement the + org.jooq.Sequence interface, providing essentially this functionality:

      + +
      +// Get a field for the CURRVAL sequence property
      +Field<BigInteger> currval();
      +
      +// Get a field for the NEXTVAL sequence property
      +Field<BigInteger> nextval();
      +

      So if you have a sequence like this in Oracle:

      +
      CREATE SEQUENCE s_author_id
      +

      This is what jOOQ will generate:

      +
      +public final class Sequences {
      +
      +    // A static sequence instance
      +    public static final Sequence S_AUTHOR_ID = // [...]
      +}
      + +

      Which you can use in a select statement as such:

      +
      +Field<BigInteger> s = Sequences.S_AUTHOR_ID.nextval();
      +BigInteger nextID   = create.select(s).fetchOne(s);
      + +

      Or directly fetch currval() and nextval() from the sequence using the Factory:

      +
      +BigInteger currval = create.currval(Sequences.S_AUTHOR_ID);
      +BigInteger nextval = create.nextval(Sequences.S_AUTHOR_ID);
      +
      diff --git a/jOOQ-website/src/main/resources/manual.xml b/jOOQ-website/src/main/resources/manual.xml index 3f770b6968..be56d78079 100644 --- a/jOOQ-website/src/main/resources/manual.xml +++ b/jOOQ-website/src/main/resources/manual.xml @@ -1973,6 +1973,41 @@ public class TBookRecord extends UpdatableRecordImpl<TBookRecord> {
      Sequences + + jOOQ also generates convenience artefacts for sequences, where this is + supported: DB2, Derby, H2, HSQLDB, Oracle, Postgres, and more. + + +

      Sequences as a source for identity values

      +

      Sequences implement the + interface, providing essentially this functionality:

      + +
      +// Get a field for the CURRVAL sequence property
      +Field<BigInteger> currval();
      +
      +// Get a field for the NEXTVAL sequence property
      +Field<BigInteger> nextval();
      +

      So if you have a sequence like this in Oracle:

      +
      CREATE SEQUENCE s_author_id
      +

      This is what jOOQ will generate:

      +
      +public final class Sequences {
      +
      +    // A static sequence instance
      +    public static final Sequence S_AUTHOR_ID = // [...]
      +}
      + +

      Which you can use in a select statement as such:

      +
      +Field<BigInteger> s = Sequences.S_AUTHOR_ID.nextval();
      +BigInteger nextID   = create.select(s).fetchOne(s);
      + +

      Or directly fetch currval() and nextval() from the sequence using the Factory:

      +
      +BigInteger currval = create.currval(Sequences.S_AUTHOR_ID);
      +BigInteger nextval = create.nextval(Sequences.S_AUTHOR_ID);
      +
      @@ -1982,6 +2017,46 @@ public class TBookRecord extends UpdatableRecordImpl<TBookRecord> {
      DSL or fluent API. Where SQL meets Java + + + +

      jOOQ ships with its own DSL (or Domain Specific Language) that + simulates SQL as good as possible in Java. This means, that you can + write SQL statements almost as if Java natively supported that syntax + just like .NET's C# does with LINQ to SQL.

      + +

      Here is an example to show you what that means. When you want to write a query like this in SQL:

      +
      The jOOQ User Manual : Meta model code generation : Sequencesprevious : next
      + + + + + + + + +
      Here is an example to show you what that means. When you want to write a query like this in SQL: Then, using jOOQ's DSL API, you can write the same query as such:
      +-- Select all books by authors born after 1920, 
      +-- named "Paulo" from a catalogue:
      +SELECT * 
      +  FROM t_author a 
      +  JOIN t_book b ON a.id = b.author_id 
      + WHERE a.year_of_birth > 1920 
      +   AND a.first_name = 'Paulo'
      + ORDER BY b.title
      +Result<Record> result = 
      +create.select()
      +      .from(T_AUTHOR)
      +      .join(T_BOOK).on(TAuthor.ID.equal(TBook.AUTHOR_ID))
      +      .where(TAuthor.YEAR_OF_BIRTH.greaterThan(1920)
      +      .and(TAuthor.FIRST_NAME.equal("Paulo")))
      +      .orderBy(TBook.TITLE)
      +      .fetch();
      + +

      You couldn't come much closer to SQL itself in Java, without re-writing the compiler.

      + + +
      Complete SELECT syntax