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/
jOOλ is our second most popular library. It implements a set of useful extensions to the JDK's Stream API, which are useful especially when streams are sequential only, which according to our as...
https://blog.jooq.org/lesser-known-joo%CE%BB-features-useful-collectors/
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...
All SQL databases support the standard aggregate functions COUNT(), SUM(), AVG(), MIN(), MAX(). Some databases support other aggregate functions, like: EVERY() STDDEV_POP() STDDEV_SAMP() VAR_POP(...
https://blog.jooq.org/writing-custom-aggregate-functions-in-sql/
In some cases, it's really useful to be able to compile a class at runtime using the java.compiler module. You can e.g. load a Java source file from the database, compile it on the fly, and execu...
https://blog.jooq.org/how-to-compile-a-class-at-runtime-with-java-8-and-9/
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/
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/
Notice, this issue has been fixed in Java 8 (8u222), thanks for the comment Zheka Kozlov In a recent article, I've shown that programmers should always apply a filter first, map later strategy wi...
https://blog.jooq.org/are-java-8-streams-truly-lazy-not-completely/
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/
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/
"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/
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/
We’re excited to announce another very interesting guest post on the jOOQ Blog by John Mcclean from AOL. AOL is a global digital media and technology company, founded in 1985 and once known as ...
https://blog.jooq.org/cyclops-react-organises-the-cambrian-explosion-of-java-8-libraries/
Java 8 introduced JSR-308, which added new annotation capabilities to the Java language. Most importantly: Type annotations. It is now possible to design monsters like the below: https://twitter....
https://blog.jooq.org/jsr-308-and-the-checker-framework-add-even-more-typesafety-to-jooq-3-9/
A very interesting question was posted to Stack Overflow and reddit
just recently about Java generics. Consider the following method:
https://blog.jooq.org/the-parameterless-generic-method-antipattern/
Welcome to the jOOQ Tuesdays series. In this series, we’ll publish an article on the third Tuesday every other month where we interview someone we find exciting in our industry from a jOOQ pers...
https://blog.jooq.org/jooq-tuesdays-ming-yee-iu-gives-insight-into-language-integrated-querying/
An interesting question by Tagir Valeev on Stack Overflow has recently caught my attention. To keep things short (read the question for details), while the following code works: public static Str...
https://blog.jooq.org/watch-out-for-recursion-in-java-8s-primitivestream-iterate/
News could hardly get more exciting than this, for a programming language aficionado! There is now a JEP 286 for Local-Variable Type Inference with status "Candidate". And a request for feedback ...
https://blog.jooq.org/java-as-new-local-variable-type-inference/
With jOOQ 3.7, we have finally added formal support for Java 8
features. This opened the door to a lot of nice improvements, such as:
Creating result streams try (Stream
https://blog.jooq.org/how-to-support-java-6-8-9-in-a-single-api/
If you're programming in more advanced languages like Scala or Ceylon, or even JavaScript, "nested functions" or "local functions" are a very common idiom to you. For instance, you'll write thing...
https://blog.jooq.org/abusing-java-8-functionalinterfaces-as-local-methods/
Have you been writing a lot of code following the Mute-Design-Pattern™ lately? E.g. try { complex(); logic(); here(); } catch (Exception ignore) { // Will never happen hehe System.exit(-1); } T...
Before I move on with the actual article, I'd like to give credit to Daniel Dietrich, author of the awesome vavr library, who has had the idea before me: https://twitter.com/danieldietrich/status...
https://blog.jooq.org/an-ingenious-workaround-to-emulate-sum-types-in-java/
One of the most awesome features of the Oracle database is Oracle AQ: Oracle Database Advanced Queuing. The AQ API implements a full fledged, transactional messaging system directly in the databa...
Recently, we've published our article about the awesome window function support in jOOλ 0.9.9, which I believe is some of the best additions to the library that we've ever done. Today, we'll loo...
https://blog.jooq.org/how-to-pattern-match-files-and-display-adjacent-lines-in-java/
Sometimes, when we get pull requests for jOOQ or our other libraries, people change the code in our unit tests to be more "idiomatic JUnit". In particular, this means that they tend to change thi...
https://blog.jooq.org/use-junits-expected-exceptions-sparingly/
You heard right. Up until now, the awesome window functions were a feature uniquely reserved to SQL. Even sophisticated functional programming languages still seem to lack this beautiful function...
https://blog.jooq.org/2016-will-be-the-year-remembered-as-when-java-finally-had-window-functions/
Awesome! We're migrating our code base to Java 8. We'll replace everything by functions. Throw out design patterns. Remove object orientation. Right! Let's go! Wait a minute Java 8 has been out f...
https://blog.jooq.org/3-reasons-why-you-shouldnt-replace-your-for-loops-by-stream-foreach/
A nice feature of the Java 7 try-with-resources statement and the AutoCloseable type that was introduced to work with this statement is the fact that static code analysis tools can detect resourc...
https://blog.jooq.org/a-subtle-autocloseable-contract-change-between-java-7-and-java-8/
This isn't going to be a rant about functional programming, which is awesome. This is a warning about some practices that you are very likely going to apply to your code, which are terribly wrong...
https://blog.jooq.org/beware-of-functional-programming-in-java/
Java 8 has lambdas and streams, but no tuples, which is a shame. This is why we have implemented tuples in jOOλ - Java 8's missing parts. Tuples are really boring value type containers. Essentia...
https://blog.jooq.org/the-danger-of-subtype-polymorphism-applied-to-tuples/
Mario Fusco's popular tweet impressively shows what the main difference between imperative and functional approaches to similar algorithms really is: https://twitter.com/mariofusco/status/5719992...
https://blog.jooq.org/comparing-imperative-and-functional-algorithms-in-java-8/
I've stumbled upon an interesting Stack Overflow question by user "mip". The question was: I'm looking for a way of generating an alphabetic sequence: A, B, C, ..., Z, AA, AB, AC, ..., ZZ. This c...
https://blog.jooq.org/how-to-use-java-8-functional-programming-to-generate-an-alphabetic-sequence/
Our recent article "NULL is Not The Billion Dollar Mistake. A Counter-Rant" got us a lot of reads, controversial comments, and a 50/50 upvote / downvote ratio pretty much everywhere a blog post c...
Functional programming allows for quasi-declarative programming in a general purpose language. By using powerful fluent APIs like Java 8's Stream API, or jOOλ's sequential Stream extension Seq o...
https://blog.jooq.org/common-sql-clauses-and-their-equivalents-in-java-8-streams/
Method overloading has always been a topic with mixed feelings. We've blogged about it and the caveats that it introduces a couple of times: You Will Regret Applying Overloading with Lambdas! Kee...
https://blog.jooq.org/java-8s-method-references-put-further-restrictions-on-overloading/
(Notice, this post has been written a while ago. jOOQ now supports JSR 310 data types) There was an interesting discussion recently on the jOOQ mailing list about jOOQ's current lack of out-of-th...
https://blog.jooq.org/whats-even-harder-than-dates-and-timezones-dates-and-timezones-in-sql-jdbc/
jOOQ is a great way to do SQL in Java and Quasar fibers bring a much improved concurrency We're excited to announce another very interesting guest post on the jOOQ Blog by Fabio Tudone from Paral...
Most of your code is private, internal, proprietary, and will never be exposed to public. If that's the case, you can relax - you can refactor all of your mistakes, including those that incur bre...
https://blog.jooq.org/do-not-make-this-mistake-when-developing-an-spi/
We're very happy to announce a guest post on the jOOQ Blog written by Daniel Dietrich, Senior Software Engineer at HSH Nordbank, husband and father of three. He currently creates a pricing framew...
https://blog.jooq.org/functional-programming-in-java-8-with-vavr/
Beauty lies in the eye of the beholder. So does "ease": https://twitter.com/thjanssen123/status/588212182225039361 Thorben writes very good and useful articles about JPA, and he's recently starte...
https://blog.jooq.org/how-jpa-2-1-has-become-the-new-ejb-2-0/
You're not into the functional mood yet? Then the title might not resonate with you - but the article will! Trust me. Essentially, we want this: +------+------+------+ | col1 | col2 | col3 | +---...
https://blog.jooq.org/how-to-flatmap-a-jdbc-resultset-with-java-8/
Imagine you have a list of items: List
https://blog.jooq.org/how-to-use-java-8-streams-to-swiftly-replace-elements-in-a-list/
Some queries shouldn't hit the database all the time. When you query for master data (such as system settings, languages, translations, etc.), for instance, you may want to avoid sending the same...
https://blog.jooq.org/hack-up-a-simple-jdbc-resultset-cache-using-jooqs-mockdataprovider/
One year ago, on March 18, 2014, Java SE 8 was released, and with it, the bliss of functional programming through lambda expressions and the streams API. These were great news for all of our Java...
https://blog.jooq.org/one-year-after-java-8s-release-ides-and-compilers-are-not-fully-ready-yet/
Sometimes we give terrible advice. Like in that article about how to use Java 8 for a cached, functional approach to calculating fibonacci numbers. As Matthias, one of our readers, noticed in the...
https://blog.jooq.org/avoid-recursion-in-concurrenthashmap-computeifabsent/
There has been a lot of hype about the buzzword "web scale", and people are going through lengths of reorganising their application architecture to get their systems to "scale". But what is scali...
https://blog.jooq.org/top-10-easy-performance-optimisations-in-java/
Writing good APIs is hard. Extremely hard. You have to think of an incredible amount of things if you want your users to love your API. You have to find the right balance between: Usefulness Usab...
https://blog.jooq.org/you-will-regret-applying-overloading-with-lambdas/