Added some sections to the manual

This commit is contained in:
Lukas Eder 2011-09-18 14:36:40 +00:00
parent 7ef097bfa6
commit 5d6eea5bde
5 changed files with 185 additions and 6 deletions

View File

@ -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;

View File

@ -79,10 +79,14 @@
}
printContent();
?>
<br/>
<br/>
</div>
<div id="footer">
<p>jOOQ is brought to you by <a href="http://lukaseder.wordpress.com" title="Lukas's Blog about Java, SQL, and jOOQ">Lukas Eder</a>.
Distributed under the <a href="http://www.apache.org/licenses/LICENSE-2.0" title="Apache 2 License">Apache 2 licence</a>
</div>
</div>
</div>

View File

@ -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() {
<tr>
<td align="left" valign="top"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/DSL/">DSL or fluent API. Where SQL meets Java</a></td><td align="right" valign="top" style="white-space: nowrap"><a href="<?=$root?>/manual/META/SEQUENCE/" title="Previous section: Sequences">previous</a> : <a href="<?=$root?>/manual/DSL/SELECT/" title="Next section: Complete SELECT syntax">next</a></td>
</tr>
</table><h3>Table of contents</h3><ol>
</table>
<p>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 <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx">LINQ to SQL.</a>
</p>
<p>Here is an example to show you what that means. When you want to write a query like this in SQL: </p>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="50%">Here is an example to show you what that means. When you want to write a query like this in SQL: </td>
<td width="50%">Then, using jOOQ's DSL API, you can write the same query as such: </td>
</tr>
<tr>
<td class="left" width="50%">
<pre class="prettyprint lang-sql">
-- 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 &gt; 1920
AND a.first_name = 'Paulo'
ORDER BY b.title</pre>
</td>
<td class="right" width="50%">
<pre class="prettyprint lang-java">
Result&lt;Record&gt; 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();</pre>
</td>
</tr>
</table>
<p>You couldn't come much closer to SQL itself in Java, without re-writing the compiler. </p>
<h3>Table of contents</h3><ol>
<li>
<a href="<?=$root?>/manual/DSL/SELECT/" title="Complete SELECT syntax">Complete SELECT syntax</a>
</li>

View File

@ -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() {
<tr>
<td align="left" valign="top"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/SEQUENCE/">Sequences</a></td><td align="right" valign="top" style="white-space: nowrap"><a href="<?=$root?>/manual/META/UDT/" title="Previous section: UDT's including ARRAY and ENUM types">previous</a> : <a href="<?=$root?>/manual/DSL/" title="Next section: DSL or fluent API. Where SQL meets Java">next</a></td>
</tr>
</table><br><table cellpadding="0" cellspacing="0" border="0" width="100%">
</table>
<h2>Sequences as a source for identity values</h2>
<p> Sequences implement the
<a href="https://github.com/lukaseder/jOOQ/blob/master/jOOQ/src/main/java/org/jooq/Sequence.java" title="Internal API reference: org.jooq.Sequence">org.jooq.Sequence</a> interface, providing essentially this functionality:</p>
<pre class="prettyprint lang-java">
// Get a field for the CURRVAL sequence property
Field&lt;BigInteger&gt; currval();
// Get a field for the NEXTVAL sequence property
Field&lt;BigInteger&gt; nextval();</pre>
<p>So if you have a sequence like this in Oracle: </p>
<pre class="prettyprint lang-sql">CREATE SEQUENCE s_author_id</pre>
<p>This is what jOOQ will generate: </p>
<pre class="prettyprint lang-java">
public final class Sequences {
// A static sequence instance
public static final Sequence S_AUTHOR_ID = // [...]
}</pre>
<p>Which you can use in a select statement as such: </p>
<pre class="prettyprint lang-java">
Field&lt;BigInteger&gt; s = Sequences.S_AUTHOR_ID.nextval();
BigInteger nextID = create.select(s).fetchOne(s);</pre>
<p>Or directly fetch currval() and nextval() from the sequence using the Factory: </p>
<pre class="prettyprint lang-java">
BigInteger currval = create.currval(Sequences.S_AUTHOR_ID);
BigInteger nextval = create.nextval(Sequences.S_AUTHOR_ID);</pre>
<br><table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td align="left" valign="top"><a href="<?=$root?>/manual/">The jOOQ User Manual</a> : <a href="<?=$root?>/manual/META/">Meta model code generation</a> : <a href="<?=$root?>/manual/META/SEQUENCE/">Sequences</a></td><td align="right" valign="top" style="white-space: nowrap"><a href="<?=$root?>/manual/META/UDT/" title="Previous section: UDT's including ARRAY and ENUM types">previous</a> : <a href="<?=$root?>/manual/DSL/" title="Next section: DSL or fluent API. Where SQL meets Java">next</a></td>
</tr>

View File

@ -1973,6 +1973,41 @@ public class TBookRecord extends UpdatableRecordImpl&lt;TBookRecord&gt; {
<section id="SEQUENCE">
<title>Sequences</title>
<slogan>
jOOQ also generates convenience artefacts for sequences, where this is
supported: DB2, Derby, H2, HSQLDB, Oracle, Postgres, and more.
</slogan>
<content>
<h2>Sequences as a source for identity values</h2>
<p> Sequences implement the
<reference class="org.jooq.Sequence"/> interface, providing essentially this functionality:</p>
<pre class="prettyprint lang-java">
// Get a field for the CURRVAL sequence property
Field&lt;BigInteger&gt; currval();
// Get a field for the NEXTVAL sequence property
Field&lt;BigInteger&gt; nextval();</pre>
<p>So if you have a sequence like this in Oracle: </p>
<pre class="prettyprint lang-sql">CREATE SEQUENCE s_author_id</pre>
<p>This is what jOOQ will generate: </p>
<pre class="prettyprint lang-java">
public final class Sequences {
// A static sequence instance
public static final Sequence S_AUTHOR_ID = // [...]
}</pre>
<p>Which you can use in a select statement as such: </p>
<pre class="prettyprint lang-java">
Field&lt;BigInteger&gt; s = Sequences.S_AUTHOR_ID.nextval();
BigInteger nextID = create.select(s).fetchOne(s);</pre>
<p>Or directly fetch currval() and nextval() from the sequence using the Factory: </p>
<pre class="prettyprint lang-java">
BigInteger currval = create.currval(Sequences.S_AUTHOR_ID);
BigInteger nextval = create.nextval(Sequences.S_AUTHOR_ID);</pre>
</content>
</section>
</sections>
</section>
@ -1982,6 +2017,46 @@ public class TBookRecord extends UpdatableRecordImpl&lt;TBookRecord&gt; {
<section id="DSL">
<title>DSL or fluent API. Where SQL meets Java</title>
<slogan>
</slogan>
<content>
<p>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 <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx">LINQ to SQL.</a></p>
<p>Here is an example to show you what that means. When you want to write a query like this in SQL: </p>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="50%">Here is an example to show you what that means. When you want to write a query like this in SQL: </td>
<td width="50%">Then, using jOOQ's DSL API, you can write the same query as such: </td>
</tr>
<tr>
<td width="50%" class="left"><pre class="prettyprint lang-sql">
-- 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 &gt; 1920
AND a.first_name = 'Paulo'
ORDER BY b.title</pre></td>
<td width="50%" class="right"><pre class="prettyprint lang-java">
Result&lt;Record&gt; 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();</pre></td>
</tr>
</table>
<p>You couldn't come much closer to SQL itself in Java, without re-writing the compiler. </p>
</content>
<sections>
<section id="SELECT">
<title>Complete SELECT syntax</title>