Map Reducing a Set of Values Into a Dynamic SQL UNION Query

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 values into a dynamic UNION query like this: SELECT T.COL1 FROM T WHERE T.COL2 = 'V1' UNION SELECT T.COL1 … Continue reading Map Reducing a Set of Values Into a Dynamic SQL UNION Query

How to Order Versioned File Names Semantically in Java

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 version numbers in our files (such as a set of SQL migration scripts), then we prefer the files to be sorted in a more intuitive … Continue reading How to Order Versioned File Names Semantically in Java

Type Safe Implicit JOIN Through Path Navigation in jOOQ 3.11

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 the Sakila database, an example could be seen easily when fetching customer data: SELECT cu.first_name, cu.last_name, co.country FROM customer AS cu JOIN address … Continue reading Type Safe Implicit JOIN Through Path Navigation in jOOQ 3.11

How to Implement Your Own XJC Plugin to Generate toString(), equals(), and hashCode() Methods

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 be externalised into its own external dependency). Adding plugins to XJC when running it via Maven … Continue reading How to Implement Your Own XJC Plugin to Generate toString(), equals(), and hashCode() Methods

Calculating Tupper’s Self-Referential Formula With SQL

A really geeky way to start a Monday morning is to be nerd-sniped by the cool Fermat's Library twitter account... https://twitter.com/fermatslibrary/status/960154478224793600 ... reading up on the cool Tupper's Self-Referential Formula thinking "Can This be Done in SQL?™" As we all know from a previous article, SQL is turing complete, so the answer must be yes. … Continue reading Calculating Tupper’s Self-Referential Formula With SQL