This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
JOIN operations. Specifically,
FOREIGN KEY values may repeat themselves unnecessarily:
+----+-----------+--------------+ | ID | AUTHOR_ID | TITLE | +----+-----------+--------------+ | 1 | 1 | 1984 | | 2 | 1 | Animal Farm | | 3 | 2 | O Alquimista | | 4 | 2 | Brida | +----+-----------+--------------+
Now, if you have millions of records with only few distinct values for
AUTHOR_ID, you may not want to hold references to distinct (but equal) java.lang.Integer objects. This is specifically true for IDs of type java.util.UUID or string representations thereof. jOOQ allows you to "intern" those values:
// Interning data after fetching Result<?> r1 = create.select(BOOK.ID, BOOK.AUTHOR_ID, BOOK.TITLE) .from(BOOK) .join(AUTHOR).on(BOOK.AUTHOR_ID.eq(AUTHOR.ID)) .fetch() .intern(BOOK.AUTHOR_ID); // Interning data while fetching Result<?> r1 = create.select(BOOK.ID, BOOK.AUTHOR_ID, BOOK.TITLE) .from(BOOK) .join(AUTHOR).on(BOOK.AUTHOR_ID.eq(AUTHOR.ID)) .intern(BOOK.AUTHOR_ID) .fetch();
You can specify as many fields as you want for interning. The above has the following effect:
- If the interned Field is of type java.lang.String, then String.intern() is called upon each string
- If the interned Field is of any other type, then the call is ignored
Future versions of jOOQ will implement interning of data for non-String data types by collecting values in java.util.Set, removing duplicate instances.
Note, that jOOQ will not use interned data for identity comparisons:
string1 == string2. Interning is used only to reduce the memory footprint of org.jooq.Result objects.