Do you need to add a JDBC driver to your application, and don't know its Maven coordinates? This blog post lists the most popular drivers from the jOOQ integration tests. Look up the latest versi...
https://blog.jooq.org/maven-coordinates-of-the-most-popular-jdbc-drivers/
Occasionally, you want to write a SQL query and fetch a hierarchy of data, whose flat representation may look like this: SELECT id, parent_id, label FROM t_directory; The result might be: |id |pa...
https://blog.jooq.org/how-to-turn-a-list-of-flat-elements-into-a-hierarchy-in-java-sql-or-jooq/
This fun fact has been on my mind for a while, and a recent reddit thread about "Smuggling Checked Exceptions with Sealed Interfaces" made me write this post here. Namely, Java had union types be...
https://blog.jooq.org/javas-checked-exceptions-are-just-weird-union-types/
Java 16 includes an improvement that makes the language a bit more regular via JEP 395. The JEP says: Static members of inner classes It is currently specified to be a compile-time error if an in...
https://blog.jooq.org/write-c-style-local-static-variables-in-java-16/
I just fixed a bug. The fix required me to initialise an Object[] array with the init values for each type, instead of just null, i.e. false for boolean, 0 for int, 0.0 for double, etc. So, inste...
https://blog.jooq.org/could-we-have-a-language-that-hides-collections-from-us/
One of the Stream APIs greatest features is its laziness. The whole pipeline is constructed lazily, stored as a set of instructions, akin to a SQL execution plan. Only when we invoke a terminal o...
https://blog.jooq.org/a-quick-trick-to-make-a-java-stream-construction-lazy/
How to write a simple API is already an art on its own. I didn't have time to write a short letter, so I wrote a long one instead. ― Mark Twain But keeping an API simple for beginners and most ...
https://blog.jooq.org/how-to-write-a-simple-yet-extensible-api/
Annotation processors can be useful as a hacky workaround to get some language feature into the Java language. jOOQ also has an annotation processor that helps validate SQL syntax for: Plain SQL ...
https://blog.jooq.org/how-to-unit-test-your-annotation-processor-using-joor/
Reporting a bug takes time, and trust me, every vendor appreciates your reporting of a bug! Your voice counts as many voices, for all the other customers of a product who do not want to or cannot...
https://blog.jooq.org/how-to-create-a-good-mcve-minimal-complete-verifiable-example/
I like weird, yet concise language constructs and API usages https://twitter.com/nipafx/status/1055451667079008256 Yes. I am guilty. Evil? Don't know. But guilty. I heavily use and abuse the java...
Clock's ticking. JDK 11 will remove a bunch of deprecated modules through JEP 320, which includes the Java EE modules, which again includes JAXB, a dependency of many libraries, including jOOQ. T...
https://blog.jooq.org/how-to-patch-your-ide-to-fix-an-urgent-bug/
In this much overdue article, I will explain why I think that in almost all cases, you should implement a "database first" design in your application's data models, rather than a "Java first" des...
https://blog.jooq.org/truth-first-or-why-you-should-mostly-implement-database-first-designs/
When inserting records into SQL databases, we often want to fetch back generated IDs and possibly other trigger, sequence, or default generated values. Let's assume we have the following table: -...
https://blog.jooq.org/how-to-run-a-bulk-insert-returning-statement-with-oracle-and-jdbc/
In a previous blog post, I've shown how the programmatic MockDataProvider can be used to mock the entire JDBC API through a single functional interface: // context contains the SQL string and bin...
https://blog.jooq.org/mocking-jdbc-using-a-set-of-sql-string-result-pairs/
If you've been following the fast paced JDK 9+ projects, you may have noticed an exciting, first big change that has been made possible thanks to Java 9's Jigsaw feature. In JDK 11, JEP 320 will ...
https://blog.jooq.org/a-completely-overhauled-modularised-jooq-3-11-ready-for-java-11/
When performing reflective access to default methods in Java, Google seems to fail us. The solutions presented on Stack Overflow, for instance, seem to work only in a certain set of cases, and no...
https://blog.jooq.org/correct-reflective-access-to-interface-default-methods-in-java-8-9-10/
Sounds fancy, right? But it's a really nice and reasonable approach to doing dynamic SQL with jOOQ. This blog post is inspired by a Stack Overflow question, where a user wanted to turn a set of v...
https://blog.jooq.org/map-reducing-a-set-of-values-into-a-dynamic-sql-union-query/
In most cases, natural sorting by sorting lexicographically is useful as a default in Java. This includes sorting file names, which are sorted lexicographically as well. However, when we have ver...
https://blog.jooq.org/how-to-order-file-names-semantically-in-java/
One of the biggest contributors to SQL syntax verbosity is the need to explicitly JOIN every table that somehow contributes to the query, even if that contribution is "trivial". When looking at t...
https://blog.jooq.org/type-safe-implicit-join-through-path-navigation-in-jooq-3-11/
When you work with JAXB to generate Java code from XSD (or *ghasp* WSDL) files, you're going to use the XJC tool, which is shipped with the JDK (at least until JDK 9 - with Jigsaw, it will soon b...
When working with Oracle stored procedures, it is not uncommon to have debug log information available from DBMS_OUTPUT commands. For instance, if we have a procedure like this: CREATE TABLE my_t...
https://blog.jooq.org/how-to-fetch-oracle-dbms_output-from-jdbc/
Caching is hard in various ways. Whenever you're caching things, you have to at least think of: Memory consumption Invalidation In this article, I want to show a flaw that often sneaks into custo...
https://blog.jooq.org/a-common-mistake-developers-make-when-caching-nullable-values/
jOOQ is a very backwards compatible product. This doesn't only mean that we keep our own API backwards compatible as well as possible, but we also still support Java 6 in our commercial distribut...
https://blog.jooq.org/how-to-ensure-your-code-works-with-older-jdks/
After the successful release of JDK 9, we can already look forward, and play around with early access releases of JDK 10. The list of JEPs currently targeted for JDK 10 is quite manageable so far...
https://blog.jooq.org/using-jdk-10s-local-variable-type-inference-with-jooq/
In this post, we're going to discuss a couple of recent efforts to squeeze roughly 10% in terms of speed out of jOOQ by iterating on hotspots that were detected using JMC (Java Mission Control) a...
https://blog.jooq.org/squeezing-another-10-speed-increase-out-of-jooq-using-jmc-and-jmh/
What's better? Using the JDK's String.replace() or something like Apache Commons Lang's Apache Commons Lang's StringUtils.replace()? In this article, I'll compare the two, first in a profiling se...
https://blog.jooq.org/benchmarking-jdk-string-replace-vs-apache-commons-stringutils-replace/
One of the cooler hidden features in jOOQ is the JPADatabase, which allows for reverse engineering a pre-existing set of JPA-annotated entities to generate jOOQ code. For instance, you could writ...
https://blog.jooq.org/jooq-3-10-supports-jpa-attributeconverter/
Java's visibility rules are tricky at times. Do you know what this will print? package p; import static p.A.x; class A { static String x = "A.x"; } class B { String x = "B.x"; } class C { String ...
https://blog.jooq.org/a-curious-java-language-feature-and-how-it-produced-a-subtle-bug/
As we all agree, GOTO is evil, right? Relevant XKCD Or even funnier: New Intern Knows Best Of course, GOTO isn't evil Of course, somewhere deep down in our professional selves, we know that GOTO ...
https://blog.jooq.org/dont-overdo-the-principle-of-least-astonishment-cargo-cult/
Every now and then, I tweet something like this, just to piss off some clean coders: https://twitter.com/lukaseder/status/885498470542577673 Apart from the obvious trolling factor (why can't I ev...
https://blog.jooq.org/dont-extract-everything-into-a-method/
You know JDBC, right? It's that really easy, concise API that we love to use to work with virtually any database, relational or not. It has essentially three types that you need to care about: Co...
https://blog.jooq.org/how-i-incorrectly-fetched-jdbc-resultsets-again/
In recent days, I've seen a bit too much of this: someCollection .stream() .map(e -> someFunction(e)) .collect(Collectors.toList()) .subList(0, 2); Something is very wrong with the above example....
https://blog.jooq.org/a-basic-programming-pattern-filter-first-map-later/
In this article, I will establish how the SQL language and its implementations distinguish between changed values and modified values, where a changed value is a value that has been "touched", bu...
https://blog.jooq.org/orms-should-update-changed-values-not-just-modified-ones/
I was recently asked in an interview about my opinion on how to be a great programmer. That's an interesting question, and I think we can all be great programmers, regardless of our talent, if we...
https://blog.jooq.org/10-tips-on-how-to-be-a-great-programmer/
jOOQ is a library that loves making everything internal final and
package private. We have tons of classes like these: final class
Concat extends AbstractFunction
https://blog.jooq.org/the-open-closed-principle-is-often-not-what-you-think-it-is/
With Java 8 lambdas being available to us as a programming tool, there is a "new" and elegant way of constructing objects. I put "new" in quotes, because it's not new. It used to be called the st...
https://blog.jooq.org/a-nice-api-design-gem-strategy-pattern-with-lambdas/
An interesting question was asked on reddit's /r/java recently: Should Iterators be used to modify a custom Collection? Paraphrasing the question: The author wondered whether a custom java.util.I...
https://blog.jooq.org/should-i-implement-the-arcane-iterator-remove-method-yes-you-probably-should/
One of jOOQ's most powerful features is the capability of introducing custom data types, pretending the database actually understands them. For instance, when working with SQL TIMESTAMP types, us...
https://blog.jooq.org/how-to-write-a-quick-and-dirty-converter-in-jooq/
In a recent consulting gig, I was analysing a client's connection pool issue in a productive system, where during some peak loads, all the Java processes involving database interactions just star...
https://blog.jooq.org/how-to-prevent-jdbc-resource-leaks-with-jdbc-and-with-jooq/
This is one of software engineering's oldest battles. No, I'm not talking about where to put curly braces, or whether to use tabs or spaces. I mean the eternal battle between nominal typing and s...
https://blog.jooq.org/do-you-really-have-to-name-everything-in-software/
Recently, at Devoxx, I've seen this beautiful slide in a talk by Kevlin Henney https://twitter.com/lukaseder/status/796704785936293888 In his talk, he was displaying a variety of approaches to so...
https://blog.jooq.org/sql-streams-for-comprehension-its-all-the-same/
As long as we allow ourselves to write string-based dynamic SQL embedded in other programming languages like Java, we will have a certain risk of being vulnerable to SQL injection. That's a fact....
https://blog.jooq.org/prevent-sql-injection-with-sql-builders-like-jooq/
I'm not well known for my love of annotations. While I do recognise that they can serve a very limited purpose in some areas (e.g. hinting stuff to the compiler or extending the language where we...
https://blog.jooq.org/the-java-ecosystems-obsession-with-nonnull-annotations/
I'm very happy to have another interesting blog post by Vlad Mihalcea on the jOOQ blog, this time about his Open Source library flexypool. Read his previous jOOQ Tuesdays post on Hibernate here. ...
https://blog.jooq.org/applying-queueing-theory-to-dynamic-connection-pool-sizing-with-flexypool/
A recent question on Stack Overflow about jOOQ caught my attention. The question essentially asked: Why do both of these loops work? // With fetch() for (MyTableRecord rec : DSL .using(configurat...
https://blog.jooq.org/a-hidden-jooq-gem-foreach-loop-over-resultquery/
With Java 8 being mainstream now, people start using Streams for everything, even in cases where that's a bit exaggerated (a.k.a. completely nuts, if you were expecting a hyperbole here). For ins...
https://blog.jooq.org/using-joo%CE%BB-to-combine-several-java-8-collectors-into-one/
This hilarious article with a click-bait title caught my attention, recently: https://medium.com/friendship-dot-js/i-peeked-into-my-node-modules-directory-and-you-wont-believe-what-happened-next-...
https://blog.jooq.org/all-libraries-should-follow-a-zero-dependency-policy/
"Challenge accepted" said Tagir Valeev when I recently asked the readers of the jOOQ blog to show if the Java JIT (Just-In-Time compilation) can optimise away a for loop. Tagir is the author of S...
https://blog.jooq.org/the-java-jit-compiler-is-darn-good-in-optimization/
Catchy headline, yes. But check out this Stack Overflow question by user Mike: (I'm duplicating it here on the blog, as it might be deleted soon) It's a pretty open ended question. I'll be starti...
https://blog.jooq.org/what-java-orm-do-you-prefer-and-why-sql-of-course/
A recent article about various ways to implement structural pattern matching in Java has triggered my interest: http://blog.higher-order.com/blog/2009/08/21/structural-pattern-matching-in-java Th...
https://blog.jooq.org/how-functional-programming-will-finally-do-away-with-the-gof-patterns/