Demos for the talk "Bootiful database-centric applications with jOOQ"
Important: The commits and commit messages have been written very carefully to guide you through reading this project and understanding the talk. Please take your time to study them if you don't understand something.
Slides are on speaker deck: Michael Simons
Functional wise the application deals with a simple database model storing the names, artists, genres and albums of tracks I listened to the last years. Those data in full comes from my daily foto project Daily Fratze that I've been running this year for more than 12 years.
The application demonstrates the value of jOOQ when it comes to analysis of data, an area for which ORMs like hibernate weren't designed (see comment by Gavin King on "What ORMs have taught me: just learn SQL". If you just deal with simple inserts, updates and deletes during OLTP, you're mostly fine using ORMs like JPA, even problems like the n+1 query problems are known and often solved.
But if you want to use powerful, analytic functions or have to deal with a database model that is a less than optimal fit for an ORM, than jOOQ will help you.
jOOQ is one of several quite different technologies to access relational data from Java based applications.
jOOQ is short for "Java object oriented querying" and describes a query builder framework that takes a look at your database schema, independent wether you use an Open Source database like PostgreSQL or an commercial product like Oracle Database., and provides you with a domain specific language (DSL) for generating statements.
jOOQs goal is explicitly not to shield the user from SQL but providing a type safe way to use it.
Learn in this session who you can facilitate the "magic" of Spring Boot to provide jOOQ with needed resources and then use it to publish advanced analytic queries as HTTP apis.
Along the way you learn how automatic database migrations help you to do continuous delivery even with database centric applications.
Part of the application is in actual use (the schema and some of the queries) at Daily Fratze. You can implement your own scrobble application. This version supports the following requests for now
## Get all artists curl -X "GET" "http://127.0.0.1:8080/api/artists"
## Get top n albums by some artists curl -X "GET" "http://127.0.0.1:8080/api/artists/54,86/topNAlbums"
## Get top n tracks by some artists Duplicate curl -X "GET" "http://127.0.0.1:8080/api/artists/54,86/topNTracks"
## Get cumulative plays by some artists curl -X "GET" "http://127.0.0.1:8080/api/artists/54,86/cumulativePlays"
## Get charts for a month curl -X "GET" "http://127.0.0.1:8080/api/charts/2016/5?n=40"
Creating and running the demo
The project needs a running PostgreSQL database providing a user
bootiful-databases with the same password.
The project provides the docker-maven-plugin, that creates a container providing PostgreSQL database. If you have Docker installed for your system, you can run everything with
./mvnw docker:start spring-boot:run
and access the application at http://localhost:8080.
- Spring Initializr
- Modern SQL
- Java, SQL and jOOQ
- Vlad on Hibernate
- Thoughts on Java
- Flyway by Boxfuse
- Spring Data JPA
- Repository Pattern
"Bootiful database-centric applications with jOOQ" von Michael J. Simons ist lizenziert unter einer Creative Commons Namensnennung - Nicht-kommerziell - Weitergabe unter gleichen Bedingungen 4.0 International Lizenz.