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.
The slides are inside this repository and also on Speakerdeck:
Datenbankzentrische Anwendungen mit Spring Boot und jOOQ
I have created a series of blog posts around this project, make sure to check them out:
- Database centric applications with Spring Boot and jOOQ
- Create a Oracle Database Docker container for your Spring Boot + jOOQ application
- Take control of your development databases evolution
- An HTTP api for analytic queries
- Oracle JET: JavaScript components for mere mortals?
Those posts cover the talk and the project in great detail. Please provide feedback and a star, if you like them.
Note: The talk and the slides are in German as DOAG con is a German conference, the demo, the readme and other artifacts inside this repo are in English in hope they are useful to a broader audience.
This repository contains the talk, including my notes and the complete demo, I've created for DOAG Konferenz + Ausstellung in Nürnberg.
The basic idea of this demo is to create a "cloud native" app based on Spring Boot and then using jOOQ as "database first", SQL-centric approach to your database.
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 modern sql and "the index", to use powerful, analytic functions or if you have to deal with a database model that is a less than optimal fit for an ORM, than jOOQ will help you.
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"
As DOAG Konferenz is an Oracle database centric conference, I used Oracle throughout the demo and prepared some docker scripts to get you up and running quickly.
- Go to docker.com and install docker on your machine
- Download Oracle Database 12c Release 2 Standard Edition 2 for Linux
- Go to Oracles docker images repository, download the OracleDatabase scripts and follow the instructions. Remember to add the two files from step 2 to "dockerfiles/12.2.0.1". I used the following command:
./buildDockerImage.sh -v 12.2.0.1 -s
- Then, inside this repository, create a running container of this image with
mvn docker:start
. The first start will take a while. The reason behind this is that the Oracle database files are created during the first start and not during image creation. The files are storted inside${project.basedir}/var
. There's a timeout of 30 minutes. You may have to change this if you are on a slower machine - The container exposes the following ports to localhost: 1521, 5500 and 5501. The first for SQL*Plus, the later ones for the Oracle Enterprise Manager
You can access the Enterprise manager express for the root container at https://localhost:5500/em and the container ORCLPDB1 at https://localhost:5501/em.
Use SQL*Plus to interact with the database. The admin password is a password generated during first startup and you can find it inside the container logs. The doag2016 account can be used with sqlplus doag2016/doag2016@//localhost:1521/ORCLPDB1
, the password is doag2016, too.
This demo uses the Oracle JDBC driver from the official Oracle Maven Repository under those coordinates:
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>orai18n</artifactId>
</dependency>
Please follow those instructions from Oracle to make this work for your Maven installation.
This demo uses an Oracle Standard Edition 2 database, so it needs a jOOQ Professional edition to run. You can get a free, 30 days trial edition here: jOOQ Download.
- Spring Initializr
- jOOQ
- Modern SQL
- Java, SQL and jOOQ
- Vlad on Hibernate
- Thoughts on Java
- Flyway by Boxfuse
- Spring Data JPA
- Repository Pattern
"Database centric applications with Spring Boot and jOOQ" von Michael J. Simons ist lizenziert unter einer Creative Commons Namensnennung - Nicht-kommerziell - Weitergabe unter gleichen Bedingungen 4.0 International Lizenz.
- "Relentless Persistence": © Curtis Lassam, Cube Drone
- "Electronic data": © iStockphoto.com/shironosov
- "Magnet und Blanko-Kühlschrank": © iStockphoto.com/andy0man
- "Oracle Databases": Public Domain
- "Young men with tablet": © iStockphoto.com/boggy22