Java的ORM框架 jOOQ 1.6.8 发布

jopen 13年前
     <p>jOOQ 高效的合并了复杂SQL、类型安全、源码生成、Active Records、存储过程以及高级数据类型的 Java 类库。<br /> <br /> 示例代码:</p>    <pre class="brush:java; toolbar: true; auto-links: false;">Result<Record> result =, LAST_NAME, create.count())        .from(AUTHOR)        .join(BOOK).on(Author.ID.equal(Book.AUTHOR_ID))        .where(LANGUAGE.equal("DE"))        .and(PUBLISHED.greaterThan(parseDate('2008-01-01')))        .groupBy(FIRST_NAME, LAST_NAME)        .having(create.count().greaterThan(5))        .orderBy(LAST_NAME.asc().nullsFirst())        .limit(2)        .offset(1)        .forUpdate()        .of(FIRST_NAME, LAST_NAME)        .fetch();</pre>    <br /> jOOQ 1.6.8 发布了,该版本重新设计了存储过程和函数 API 。    <br /> 项目地址:    <a href="/misc/goto?guid=4958183625154729377" target="_blank"></a>    <p></p>    <h2 id="WhatsjOOQ">What's jOOQ</h2>    <p>jOOQ stands for Java Object Oriented Querying. It combines these essential features:</p>    <ul>     <li><strong>Code Generation</strong>:<br /> jOOQ generates a simple Java representation of your database schema. Every table, view, stored procedure, enum, UDT is a class.<br /> <br /> </li>     <li><strong>Active records</strong>:<br /> jOOQ implements an easy-to-use active record pattern. It is NOT an OR-mapper, but provides a 1:1 mapping between tables/views and classes. Between columns and members.<br /> <br /> </li>     <li><strong>Typesafe SQL</strong>:<br /> jOOQ allows for writing compile-time typesafe querying using its built-in DSL.<br /> <br /> </li>     <li><strong>SQL standard</strong>:<br /> jOOQ supports all standard SQL language features including the more complex UNION's, nested SELECTs, joins, aliasing<br /> <br /> </li>     <li><strong>Vendor-specific feature support</strong>:<br /> jOOQ encourages the use of vendor-specific extensions such as <a class="wiki" href="/misc/goto?guid=4958195218649539171">stored procedures</a>, <a class="wiki" href="/misc/goto?guid=4958195219397682579">UDT's and ARRAY's</a>, <a class="wiki" href="/misc/goto?guid=4958195220128817426">recursive queries</a>, and many more.<br /> <br /> </li>    </ul>    <h2 id="HowdoesjOOQhelpyou">How does jOOQ help you?</h2>    <ul>     <li>Your database always comes FIRST! That's where the real schema is, not in your Java code or some XML mapping file.</li>     <li>Your schema is generated in Java. You can use auto-completion in your IDE!</li>     <li>Your "value objects" or "data transfer objects" are generated too. This keeps things <a class="ext-link" href="/misc/goto?guid=4958195220874856455"><span class="icon">DRY</span></a> </li>     <li>Your Java code won't compile anymore when you modify your schema. That means less runtime errors.</li>     <li>You and your DBA can be friends again because you have full control over your SQL.</li>     <li>You can port your SQL to a new database. jOOQ will generate SQL that works on any database.</li>     <li>You won't have syntax errors in your query.</li>     <li>You won't forget to bind variables correctly. No SQL injection, either.</li>     <li>You can forget about JDBC's verbosity (especially useful when dealing with UDTs, ARRAYs and stored procedures).</li>    </ul>    <p>Or in short:</p>    <ul>     <li>You can be productive again!</li>    </ul>    <h2 id="WhentousejOOQ">When to use jOOQ</h2>    <ul>     <li>When you love your RDBMS of choice, including all its vendor-specific features.</li>     <li>When you love control over your code.</li>     <li>When you love the relational data model (read this <a class="ext-link" href="/misc/goto?guid=4958195221613782864"><span class="icon">interesting article</span></a>).</li>     <li>When you love SQL.</li>     <li>When you love stored procedures.</li>     <li>When you love both <a class="ext-link" href="/misc/goto?guid=4958195222353785672"><span class="icon">OLAP</span></a> and <a class="ext-link" href="/misc/goto?guid=4958195223086508182"><span class="icon">OLTP</span></a> </li>    </ul>    <h2 id="WhennottousejOOQ">When not to use jOOQ</h2>    <p>On the other hand, many people like the ease of use of Hibernate or other products, when it comes to simply persisting any domain model in any database. You should not use jOOQ...</p>    <ul>     <li>When you don't care about your database (or "persistence" as you would probably call it).</li>     <li>When you don't really need SQL.</li>     <li>When you want to map your object-oriented domain model to a database and not vice versa.</li>     <li>When your schema changes more frequently than you can re-deploy jOOQ-generated source code.</li>     <li>When you need to write DDL statements. jOOQ only supports DML statements.</li>    </ul>    <h2 id="Whatdatabasesaresupported">What databases are supported</h2>    <p>Every RDMBS out there has its own little specialties. We consider those specialties as much as possible, while trying to standardise the behaviour in jOOQ. In order to increase the quality of jOOQ, we run unit tests for syntax and variable binding verification, as well as integration tests for any of these databases:</p>    <ul>     <li>DB2 9.7 (v9.7 is strongly recommended. we have known issues such as <a class="closed ticket" title="defect: NULL value should be cast to an explicit type for DB2 dialect (closed: wontfix)" href="/misc/goto?guid=4958195223831247849">#172</a> for v9.5)</li>     <li>Derby 10.8</li>     <li>H2 1.3.155</li>     <li>HSQLDB 2.2.1</li>     <li>Ingres 10.1.0</li>     <li>MySQL 5.1.41 and 5.5.8</li>     <li>Oracle XE</li>     <li>PostGreSQL 9.0</li>     <li>SQLite with <a class="ext-link" href="/misc/goto?guid=4958195224561475902"><span class="icon">inofficial JDBC driver v056</span></a> </li>     <li>SQL Server 2008 R8</li>     <li>Sybase Adaptive Server Enterprise 15.5</li>     <li>Sybase SQL Anywhere 12</li>    </ul>    <p>Please <a class="ext-link" href="/misc/goto?guid=4958195225301361975"><span class="icon">report any issues</span></a> you might have with other database versions.</p>    <p>Planned (<a class="wiki" href="/misc/goto?guid=4958195226030757036">Contributions</a> and <a class="ext-link" href="/misc/goto?guid=4958195226773550844"><span class="icon">suggestions</span></a> welcome!):</p>    <ul>     <li><a class="new ticket" title="enhancement: Add Firebird support (new)" href="/misc/goto?guid=4958195227521812198">#430</a>: Firebird</li>     <li><a class="new ticket" title="enhancement: Add Informix support (new)" href="/misc/goto?guid=4958195228259296255">#561</a>: Informix</li>     <li><a class="new ticket" title="enhancement: Add Interbase support (new)" href="/misc/goto?guid=4958195228996456574">#562</a>: Interbase</li>     <li><a class="new ticket" title="defect: Add support for SQL Azure (new)" href="/misc/goto?guid=4958195229734608866">#659</a>: SQL Azure</li>     <li><a class="new ticket" title="enhancement: Add Teradata support (new)" href="/misc/goto?guid=4958195230473602918">#629</a>: Teradata</li>    </ul>    <h2 id="Otherrequirements">Other requirements</h2>    <ul>     <li>jOOQ runs with Java 1.6+</li>    </ul>    <h2 id="License">License</h2>    <p>jOOQ is licensed under the <a class="ext-link" href="/misc/goto?guid=4958193982591036976"><span class="icon">Apache Software License 2.0</span></a> </p>    <p></p>