diff --git a/jOOQ-website/src/main/resources/manual-2.5.xml b/jOOQ-website/src/main/resources/manual-2.5.xml index 4f9087af92..4086b01ec9 100644 --- a/jOOQ-website/src/main/resources/manual-2.5.xml +++ b/jOOQ-website/src/main/resources/manual-2.5.xml @@ -4123,11 +4123,78 @@ Query query = error.query();]]>
CRUD with UpdatableRecords - + +

CRUD: Create, Read, Update, Delete

+

+ Your database application probably consists of 50% - 80% CRUD, whereas only the remaining 20% - 50% of querying is actual querying. Most often, you will operate on records of tables without using any advanced relational concepts. This is called CRUD for +

+ +

+ CRUD always uses the same patterns, regardless of the nature of underlying tables. This again, leads to a lot of boilerplate code, if you have to issue your statements yourself. Like Hibernate / JPA and other ORMs, jOOQ facilitates CRUD using a specific API involving types. +

+ +

Primary keys and updatability

+

+ In normalised databases, every table has a primary key by which a tuple/record within that table can be uniquely identified. In simple cases, this is a (possibly auto-generated) number called ID. But in many cases, primary keys include several non-numeric columns. An important feature of such keys is the fact that in most databases, they are enforced using an index that allows for very fast random access to the table. A typical way to access / modify / delete a book is this: +

+ + + +

+ Normalised databases assume that a primary key is unique "forever", i.e. that a key, once inserted into a table, will never be changed or re-inserted after deletion. In order to use jOOQ's operations correctly, you should design your database accordingly. +

+ +

Main UNIQUE keys

+

+ In SQL, a primary key is always also a unique key. In fact, unique keys have very similar properties as primary keys. For instance, they can be referenced from other tables' foreign keys in most databases. In the absence of a formal primary key, jOOQ assumes that the first unique key it encounters will serve as a primary key substitute. This is called the "main key" in jOOQ. In other words, a main key is: +

+ + +

+ For simplicity, the term "primary key" will be used in the sense of such a "main unique key" in this manual. +

+
Simple CRUD + +

Simple CRUD performed with jOOQ

+

+ If you're using jOOQ's , it will generate implementations for every table that has a primary key. When such a record form the database, these records are "attached" to the that created them. This means that they hold an internal reference to the same database connection that was used to fetch them. This connection is used internally by any of the following methods of the UpdatableRecord: +

+ + + +

+ See the manual's section about for some more insight on "attached" objects. +

+
+
+ +
+ IDENTITY values
@@ -4153,6 +4220,11 @@ Query query = error.query();]]>
+
+ Exception handling + +
+
ExecuteListeners @@ -4266,6 +4338,31 @@ Query query = error.query();]]> +
+ Unsigned integer types + +

Unsigned integers in jOOQ

+

+ Some databases explicitly support unsigned integer data types. In most normal JDBC-based applications, they would just be mapped to their signed counterparts letting bit-wise shifting and tweaking to the user. jOOQ ships with a set of unsigned implementations modelling the following types: +

+
    +
  • : Unsigned byte, an 8-bit unsigned integer
  • +
  • : Unsigned short, a 16-bit unsigned integer
  • +
  • : Unsigned int, a 32-bit unsigned integer
  • +
  • : Unsigned long, a 64-bit unsigned integer
  • +
+

+ Each of these wrapper types extends , wrapping a higher-level integer type, internally: +

+
    +
  • UByte wraps
  • +
  • UShort wraps
  • +
  • UInteger wraps
  • +
  • ULong wraps
  • +
+
+
+
INTERVAL data types