Home » Author Archives: Lukas Eder

Author Archives: Lukas Eder

Lukas is a Java and SQL enthusiast developer. He created the Data Geekery GmbH. He is the creator of jOOQ, a comprehensive SQL library for Java, and he is blogging mostly about these three topics: Java, SQL and jOOQ.

Using Stored Procedures With JPA, JDBC. Meh, Just Use jOOQ

jooq-logo

The current edition of the Java magazine has an article about Big Data Best Practices for JDBC and JPA by Josh Juneau: http://www.javamagazine.mozaicreader.com/MayJune2016 The article shows how to use a stored procedure with JDBC (notice how resources aren’t closed, unfortunately. This is commonly forgotten, even in Java Magazine articles) // Using JDBC to call upon a database stored // procedure CallableStatement ...

Read More »

Correlated Subqueries are Evil and Slow. Or are They?

software-development-2-logo

A common myth in SQL is the idea that correlated subqueries are evil and slow. For example, this query here: SELECT first_name, last_name, (SELECT count(*) FROM film_actor fa WHERE fa.actor_id = a.actor_id) FROM actor a It “forces” the database engine to run a nested loop of the form (in pseudo code): for (Actor a : actor) { output( a.first_name, a.last_name, ...

Read More »

JSR-308 and the Checker Framework Add Even More Typesafety to jOOQ 3.9

jooq-2-logo

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: The only thing crazier than annotations are type annotations. On arrays. Who thinks this is valid Java code? pic.twitter.com/M9fSRRerAD — Lukas Eder (@lukaseder) March 20, 2016 The code displayed in that tweet really ...

Read More »

10 SQL Tricks That You Didn’t Think Were Possible

software-development-2-logo

Listicles like these do work – not only do they attract attention, if the content is also valuable (and in this case it is, trust me), the article format can be extremely entertaining. This article will bring you 10 SQL tricks that many of you might not have thought were possible. The article is a summary of my new, extremely ...

Read More »

The Parameterless Generic Method Antipattern

java-logo

A very interesting question was posted to Stack Overflow and reddit just recently about Java generics. Consider the following method: <X extends CharSequence> X getCharSequence() { return (X) "hello"; } While the unsafe cast seems a bit wonky, and you might guess there’s something wrong here, you can still go ahead and compile the following assignment in Java 8: Integer ...

Read More »

10 Features I Wish Java Would Steal From the Kotlin Language

jetbrains-kotlin-logo

This article is overdue. After the hype around the release of Kotlin 1.0 has settled, let’s have a serious look at some Kotlin language features that we should have in Java as well. In this article, I’m not going to wish for unicorns. But there are some low hanging fruit (as far as I naively can see), which could be ...

Read More »

Watch Out For Recursion in Java 8’s [Primitive]Stream.iterate()

java-logo

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 Stream<Long> longs() { return Stream.iterate(1L, i -> 1L + longs().skip(i - 1L) .findFirst() .get()); } longs().limit(5).forEach(System.out::println); printing 1 2 3 4 5 The following, similar code won’t work: public static ...

Read More »

Time for some Funky SQL: Prefix Sum Calculation

software-development-2-logo

This Stack Overflow question has yet again nerd-sniped me: [finding the] maximum element in the array that would result from performing all M operations Here’s the question by John that was looking for a Java solution: With an array of N elements which are initialized to 0. we are given a sequence of M operations of the sort (p; q; ...

Read More »

Improve Your JUnit Experience with this Annotation

junit-logo

JUnit is probably part of 90% of all Java projects. And the exciting thing is, we’ll soon have JUnit 5 with Java 8 support. We’ve blogged about an improvement recently. Back in JUnit 4 land, there’s this little trick that I can only recommend you put in all of your unit tests. Just add this little annotation here and you’ll ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials