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 breaking API changes. If you're maintining public API, however, that's not the case. If you're maintaining public SPI (Service Provider Interfaces), … Continue reading Do Not Make This Mistake When Developing an SPI
How to Access a Method’s Result Value From the Finally Block
While the JVM is a stack-based machine, the Java language doesn't really offer you any way to access that Stack. Even if sometimes, in rare occasions, it would be very useful. An example Method result values are put on the stack. If you look at the following example: public int method() { if (something) return … Continue reading How to Access a Method’s Result Value From the Finally Block
Use This Preference to Speed up Your Eclipse m2e Configuration
Who doesn't know them. The good old JFace dialogs in Eclipse that give you a visual representation of what is really a rather simple XML or properties file. In the case of m2e, it looks like this: Unfortunately, this screen is a bit slow to load, and it doesn't offer much value beyond checking version … Continue reading Use This Preference to Speed up Your Eclipse m2e Configuration
Functional Programming in Java 8 with vavr
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 framework for financial products as project lead and lead developer. Besides his work, he is interested in programming languages, efficient algorithms and data … Continue reading Functional Programming in Java 8 with vavr
Use this Neat Window Function Trick to Calculate Time Differences in a Time Series
Whenever you feel that itch... Can't I calculate this with SQL? The answer is: Yes you can! And you should! Let's see how... Calculating time differences between rows Let's consider the following database containing timestamps (e.g. in a log database). We're using PostgreSQL syntax for this: CREATE TABLE timestamps ( ts timestamp ); INSERT INTO … Continue reading Use this Neat Window Function Trick to Calculate Time Differences in a Time Series
PostgreSQL’s Best-Kept Secret, and how to Use it with jOOQ
PostgreSQL has a lot of secret data types. In recent times, PostgreSQL's JSON and JSONB support was hyped as being the NoSQL on SQL secret (e.g. as advertised by ToroDB) that allows you to get the best out of both worlds. But there are many other useful data types, among which the range type. How … Continue reading PostgreSQL’s Best-Kept Secret, and how to Use it with jOOQ
How SQL GROUP BY Should Have Been Designed – Like Neo4j’s Implicit GROUP BY
In the recent past, we've explained the syntactic implications of the SQL GROUP BY clause. If you haven't already, you should read our article "Do You Really Understand SQL’s GROUP BY and HAVING clauses?". In essence, adding a GROUP BY clause to your query transforms your query on very implicit levels. The following reminder summarises … Continue reading How SQL GROUP BY Should Have Been Designed – Like Neo4j’s Implicit GROUP BY
This Common API Technique is Actually an Anti-Pattern
I admit, we've been lured into using this technique as well. It's just so convenient, as it allows for avoiding a seemingly unnecessary cast. It's the following technique here: interface SomeWrapper { <T> T get(); } Now you can type safely assign anything from the wrapper to any type: SomeWrapper wrapper = ... // Obviously … Continue reading This Common API Technique is Actually an Anti-Pattern
Do Not Think That One Second is Fast for Query Execution
I keep encountering situations where RDBMS users think that one second for query execution is anything near fast. Most recently, in this Stack Overflow question: Hibernate SQL In clause making CPU usage to 100% The poster's original question was why a similar query executes in one second when executed in SQL Server Management Studio whereas … Continue reading Do Not Think That One Second is Fast for Query Execution
Let’s Review How to Insert Clob or Blob via JDBC
LOBs are a PITA in all databases, as well as in JDBC. Handling them correctly takes a couple of lines of code, and you can be sure that you'll get it wrong eventually. Because you have to think of a couple of things: Foremost, LOBs are heavy resources that need special lifecycle management. Once you've … Continue reading Let’s Review How to Insert Clob or Blob via JDBC
