Category: Database

by Streams introduced a declarative approach to Collection processing which makes its API extremely easy to use, allowing developers to express their thoughts in seconds.

In the first part of the Intro to Speedment guide we created a fresh Speedment project and at the very end, we executed a simple query to show that everything is working as it should.

If we were to sort by the actor's first name, we would do something like this: This is the output of our new Stream: And this is the SQL that Speedment generated: Let's say we wanted to sort by the actor's full name, meaning we would sort by their last name and then by their first name, if there were duplicate last names. This can be done easily using Comparator::thenComparing: If we run this, we can see that the actors that have matching last names are sorted based on their first name: This is the SQL that Speedment generated: Java Streams and SQL share a lot of similarities in their core, allowing us to express SQL queries as pure Java Streams.

Related Articles