136
[email protected] Introduction to Db - Jdbc - JPA - SpringData This document: http://arnaud-nauwynck.github.io/docs/Intro-DB-Jdbc- JPA-SpringData.pdf

Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

  • Upload
    others

  • View
    51

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

[email protected]

Introduction to Db - Jdbc - JPA - SpringData

This document:http://arnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-

JPA-SpringData.pdf

Page 2: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver
Page 3: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SQL Client Driver(1) < DataBase< B-Tree File

< JDBC API(2) < Driver Impl.

Spring JDBC

< JPA API - JPQL(3) < Hibernate/EclipseLink

Spring JPAQueryDsl

(4) < Spring Data

Page 4: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 5: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Structured Query LangageSQL = DDL + DML

Page 6: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Oracle Sample DataBasehttps://github.com/oracle/db-sample-schemas/

human_resources/hr_cre.sql

Page 7: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

UML Employee - Department

Employee

0..1 manager

Department0..1 dept* employees

0..1 deptManager

Page 8: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Example using PGAdmin3

Page 9: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SQL SELECT

Simple(with WHERE clause)

With “JOIN .. ON”(and GROUP BY)

With SubQueries

Page 10: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SQL DML

Page 11: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Detailed CRUD

INSERT into <Table..> (col1, col2, …)VALUES (?0, ?1, 123, ..)

SELECT * from <Table..> where <expr..>

UPDATE col1=value1, col2=… from <Table..> where <expr..>

DELETE from <Table..>where <expr..>

CRUD =

Create

Read

Update

Delete

Page 12: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Emp-Dept CRUD Sample

Page 13: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Emp-Dept Queries

Page 14: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SQL Exerciseshttp://www.w3resource.com/sql-exercises/sql-subqueries-

exercises.php

Page 15: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 16: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SQL Merge (=Upsert)

Page 17: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

[ With Col1, Col2 from Table1... ]

select /*+HINT */ Col1, Col2 as prettyName, function(col3,col4)from Table1 alias1, Table2 alias2, (inner/outer..) join Table3 alias3 on ..where Col1 = 123 - - Literal Value and Col2 = ?0 - - Bind-Variable … ?0=123 and Col3 = Col4 and alias1.Col1 = alias2.Col2 – explicit JOIN with alias[ limit .. firstRows .. cf also rownum ]Order by Col2 asc, Col3 desc

Simple SELECT Query

Page 18: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Aggregate Query

select C1, C2, count(*), avg(Col3), min(Col4) ..from Table ..where ...Group by C1, C2

Having ..

Order by ...

Page 19: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SQL Nested Queries

Example 2: select .. from (select .. where ..) where .. not in (select ..where )

Page 20: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Analytical Query Functions

select … analyticalFunc[first,last,nth,min,max,avg,..](..) OVER (PARTITION BY ..)from … where ..

Page 21: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Hierarchical QueriesExemple: clause “where” using Hierarchy

Page 22: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Advanced Bulk Update

with PL/SQL + Array

CREATE OR REPLACE PROCEDURE ..(a ARRAY) ISCURSOR c IS select .. from TABLE(CAST(a ..))BEGIN OPEN c; LOOP FETCH c BULK COLLECT INTO ...; END

Page 23: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 24: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

B-Tree = Balanced-Tree (not only Binary Tree)

Page 25: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

B-Tree

a self-balancing tree data structure that keeps data sorted and allows searches, sequential access, insertions, and deletions in logarithmic time.

Page 26: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Sort/Compare Rows – Columns ?

( 123, “Text2”, FALSE, +1e3, 'b' )

<?== ?> ?

(col1, col2, col3, col4, col5) (col1, col2, col3, col4, col5)

( 123, “Hello”, FALSE, +1e3, 'b' )

Choose columns … exemple: Sort (col1) Sort (col3,col5,col2)

Page 27: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Lexicographical Compare Rows

1 Row = N Columns

Compare row by Col1,Col2,ColK :

if (a.col1 < a.col1) => -1else if (a.col1 > a.col1) => +1else { if (a.col2 < b.col2) … => .. .. { … => 0} }

Page 28: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

B-Tree on (Col1,Col2...) = INDEX

PK INDEX : col (ID)

INDEX2 : (Col2,Col3,ID)

INDEX3 : (Col3,Col2,Col6)

Insert ROW = (ACID : Atomic) Insert Data + Insert Index1 + Insert Index2 + ….

Page 29: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Select .. where ID = ?

Execution Plan

Step 1: Index Lookup (Unique) by ID Log(N) logical reads

=> get “rowId” (=address)

Step 2: table lookup by RowId (=O(1)) => get other columns

Page 30: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Select .. where C2=? and C3=? ..… with INDEX (C2,C3,otherC...)

Execution Plan

Step 1: Index Range Scan lookup = Log(N) logical reads + scan non unique

=> foreach.. get “rowId” (=address)

Loop Step 2: table lookup by RowId (=O(1)) => get other columns

Page 31: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Applicable Index(es) ?for “.. where Col2=? And Col5=?”

PK INDEX : col (ID)

INDEX (Col2,Col6,Col5)

INDEX (Col2,Col5,Col6)

INDEX (Col5,Col2,Col7)

INDEX (Col1,Col2,Col5)

Applicable =Allow Lexicographical Top->Down Search

Page 32: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Select C3,C4 where C1=?,C2=?With INDEX(C1,C2,..C3,C4)

Execution Plan

Step 1: Index Lookup by ID Log(N) logical reads ...unique/scan

=> read Col3,Col4 value from INDEX

.. NO need table lookup by rowid

Optim = Index Coverage

Page 33: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Query Execution Engine

“Select ..from ..where .. col1='val1'and col2=123“

Execute Query

Result : Tabular Data Format = “ResultSet”

Page 34: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Huge Result .. Server-Side “Cursor”

Result = Partial Data + Cursor (= handle of server-side Partial Data+ Iterator)

Begin “Execute” Query

Fetch next page

Fetch next page

Fetch next page

CLOSE CURSOR !!

Page 35: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SoftParse – HardParse … PrepareQuery + BindVariable

“Select ..from ..where .. col1=?0and col2=?1“

BindVariable: set(0, “val1”) set(1, 1234)

First Seen ? HARD Parse

Already Seen ? SOFT Parse= create Cursor

Compute Execution Plan

Put in Cache

Page 36: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Explain Execution Plan

Page 37: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Query / Prepared Query ExecutionSelect ..from ..where .. col1=?0and col2=?1

Prepare (SQL)

PreparedStatement

ExecuteQuery

ResultSet (page1)

Fetch next page

BindVariable: set(0, “val1”) set(1, 1234)

Next rowget col1, get col2 …next row...

Page 38: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

… = JDBC API Explained

Page 39: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 40: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

import java.sql.*;

DataSource Connection PreparedStatement ResultSet

Page 41: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Sample Jdbc (Test with Rollback)

Page 42: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Refactored (1/2)

Page 43: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Refactored (2/2)“Template” + Callback

Common TemplateFramework

.. similar to Spring Template

Code to run with Cx+ rollback

Page 44: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Data Transfer Object for CRUD

Page 45: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

CRUD 1 / 4 : SELECT

Page 46: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Jdbc is As Verbose as Easy ...

Is it DRY ?

D don'tR repeat Y yourself

Page 47: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

CRUD 2 / 4 : INSERT

Page 48: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

CRUD 3 / 4 : UPDATE (All columns)

Page 49: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

UPDATE with Versioning

Page 50: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

CRUD 4 / 4 : DELETE

Page 51: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Check my Foreign Keys …

Looks the simplest code to DELETE ? …It is the hardest to execute safely !!

Because you must clear all incoming Foreign Keys to this PK first

Page 52: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

And What About INSERT...Chicken & Egg

How to ?

INSERT CHICKEN .. FK to EGG ID (not exist yet)INSERT EGG .. FK to CHICKEN ID (not exist yet)

Solution 1/INSERT nextval(..)… CHICKEN … NULL FK) => newChickenIDINSERT nextval(..)… EGG … CHICKEN_ID => newEggIDUPDATE CHICKEN set EGG_ID = newEggID

Solution 2/ … use Database Deferred Constraint CheckSelect nextval(..) => newChickenID Select nextval(..) => newEggIdINSERT … CHICKEN … newChickenID –-- no exist yet .. deferred check!INSERT … EGG … newEggID

Page 53: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 54: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

javax.sql.DataSource(remark: javax.* not java.* )

DataSource Connection

Page 55: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

javax.sql.XADataSource

Connection

XADataSource XAConnection

XAResource

Page 56: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.Connection (1/3)

PreparedStatement

CallableStatement

Connection Statement

create* Data

create* Statement

Page 57: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.Connection (2/3)

transaction

Connection

TransactionManager SavePoint

Page 58: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.Connection (3/3)

metadata

Connection

DatabaseMetaData

Page 59: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.PreparedStatement (1/2)

execute*

metadata

Set parameters (cf next)

PreparedStatement

Statement

ResultSet

ResultSetMetaData

Page 60: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

PreparedStatement (2/2)

set*

PreparedStatement

metadata

ParameterMetaData

clear

Page 61: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.StatementStatementConnection ResultSet

Page 62: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.CallableStatement

PreparedStatement

Statement

CallableStatement

Page 63: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.ResultSet (1/2)

ResultSet

ResultSetMetaData

Page 64: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

java.sql.ResultSet (2/2)

Page 65: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

import java.sql.*; (full)

DataSource

Driver

Connection Statement ResultSet

PreparedStatement

CallableStatement

XADataSource XAConnection

XAResource

DatabaseMetaData ResultSetMetaDataParameterMetaData

Page 66: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Jdbc Database App

Page 67: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

DataSource Code Sample

Using explicit Transaction+ commit/rollback

Using try-close

Rule for ALL Resources : If You Open It => You Close It

Page 68: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

H2 DataSource HelloWorld

Page 69: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Postgresql Hello

Page 70: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

PreparedStatement Sample

Page 71: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 72: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring-Jdbc Database App

Page 73: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot config/application.yml

Page 74: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot JDBC… “JUST work”

Page 75: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot Jdbc main()

Pooled DataSource injected

Start Spring+ inject DataSource

Page 76: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot JUnit

DataSource in injectedPooled DataSource injected

Start Spring+ inject DataSource

Page 77: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

SpringBoot … explicit DataSourceAutoConfiguration

Page 78: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Explicit @Bean (example for Multi DataSources)

Page 79: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

(Reminder) DataSource Try-Finally Close

Using explicit Transaction+ commit/rollback

Using try-close

Rule for ALL Resources : If You Open It => You Close It

Page 80: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Same using Template Spring-Jdbc

Page 81: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

PooledConnection + Transaction= Thread-Locked : reuse

XA ..

XA commit/rollback=> connection commit/rollbackTHEN repool

Thread-12

Conn

Page 82: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

(Reminder) try-finally Connection+ try-finally Statement

Page 83: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

JdbcTemplate(dataSource)

Page 84: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Run Jdbc App

Page 85: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot built-in supports JTA @Transactional

Page 86: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

@Transactional JUST Works

Page 87: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

Page 88: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

JPA (with springboot data)

Page 89: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

EntityManager (1/2)

Page 90: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

EntityManager (2/2)

Page 91: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

What is an “Entity” ?

A class with @Entity

And an @Id

Page 92: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Javax.persistence.* Annotations

Page 93: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

How many java.persistence.* Annotations ?

$ cd src/main/java/javax/persistence$ find . -name \*.java -exec grep -H '@Retention' {} \;

$ find . -name \*.java -exec grep -H '@Retention' {} \; \ | cut -d: -f1 | sed 's|\./\(.*\)\.java|\1|g' | wc -l

90

Page 94: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Sufficient @Annotations to know?

@Entity

@Id@GeneratedValue@SequenceGenerator@Version

@ManyToOne

@OneToManyFor relationshipsFK (*) → (1) PKPK (*) ← (*) FK

Base

@Inheritance

@DiscriminatorColumn

@JoinTable@JoinColumn

@Table@ColumnCustom

Sub-Classes

Page 95: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Why putting @Column & @Table ?

Page 96: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

@Id with Sequence Generator

SQL:CREATE SEQUENCE employees_seq INCREMENT BY 10;

Detailed JPA:

Page 97: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

@Version ?

whenever overwriting modified value without reading =>

version=1

(1) (2):Get data version:1

(3):Mofify + Save (on version 1)OK => increment version=2

Wait...

(4):Mofify + Save (on version 1?)=> OptimisticLockException .. version=2 !

(5):REDO fetch + update

(6):Save (on version=2)OK

Page 98: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

@Entity Employee-Department

Database table “EMPLOYEE” id (PK), version, first_name, last_name, …. department_id (FK department.id) manager_id (FK employee.id)

Database table “DEPARTMENT”id (PK), version, name, department_manager_id (FK employee.id)

Page 99: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

For real with @Column ...

Page 100: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

FindById with JPA

Page 101: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

CRUD with JPA

Page 102: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Dynamic Query( java.persistence.CriteriaBuilder )

Page 103: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Dynamic Queryusing Bind-Variables

Page 104: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Dynamic Query … String type checking?

Which one is correct??? Discover it by Exception on PROD !

cb.get(“addr”) // column name in Databasecb.get(“address”) // field name in javacb.get(“adress”) // with a Typocb.get(“city_id”).get(“name”) // after refactoring db schema

Page 105: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Generated *_ class MetaModel + Compile Type Check

Generate

Page 106: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Real MetaModel .. (Real? … see javac processor)

Page 107: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Pom.xml MetaModel plugin(example for eclipselink)

Page 108: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

DynamicCriteria using MetaModel

Page 109: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Search Parameters in Criteria class(also called “Specification”)

Page 110: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Cascading Setters with “return this”for Fluent API

Page 111: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

springboot data

Page 112: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver
Page 113: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Pom.xml QueryDsl plugin

Page 114: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

QueryDsl Generated Q* classsimilar but richer than *_ class

Page 115: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

QueryDsl++More Fluent than JPA

Page 116: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

QueryDsl + Bind-Variables !(not a clean API for parameters!!)

Page 117: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

QueryDsl Predicate (no bind-var!)

Page 118: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring JDBC

Spring JPAQueryDsl

springboot data

Page 119: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver
Page 120: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Repository

Page 121: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

extends JpaRepository

Page 122: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Repository with extra FindersfindBy XXX And YYY

Page 123: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Small + Custom + Almost Complete(see also next for QueryDsl)

By naming convention .. Equivalent to:“Select * from EMPLOYEE where email=?”

Extends JpaRepositorybuilt-in CRUD …

findAll, by Page, save, delete...(no update, use Setters)

Page 124: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Sample Codeusing springboot-data Repository

Page 125: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot @JPA configuration

Optionalfor debug (see next)

springboot dark magicnot even 1 line .. all optional !!!

Useless equivalent 2 implicit lines

Page 126: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Springboot hibernate… “JUST work”

CRUD … select * from EMPLOYEE where …

insert into EMPLOYEE (..) values (..)

Page 127: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

When/How/Where are my “create Table ()” ???

Tables are created/updated at startup

Detected H2 Database SQL langage

Also create PK/FK indexes

Page 128: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

How??

Call springboot-dataJpaRepository

You codecalls a generated

Proxy..

Which call JPA..→ Hibernate...

→ JDBC

Page 129: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

JPA Dyn Criteria + Spring-Data = Specification

( != querydsl Predicate !)

Page 130: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Spring-Data + Specification..

Page 131: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Sample spring-data Specification

Page 132: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Better.. QueryDsl + Spring-Data

Page 133: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

AngularJS + Springboot

In Jhipster … you have 100% springboot on server-side… with Code GeneratorAnd also Hipe code on client-side : Html / Css + AngularJS + ..

Page 134: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Java is HipeMake Jar nor WAR – NO PHP

NO NodeJS on server

20 years of JavaJust The Beginning

Its HIPE ...because of springboot & open-source & java community

Page 135: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Conclusion

Page 136: Introduction to Db - Jdbc - JPA - SpringDataarnaud-nauwynck.github.io/docs/Intro-DB-Jdbc-JPA-SpringData.pdf · SQL Client Driver (1) < DataBase < B-Tree File < JDBC API (2) < Driver

Conclusion

Only a (not so short) introduction to Databases < JDBC < JPA < Spring-Data

This document:http://arnaud-nauwynck.github.io/docs/Intro-Db-Jdbc-

JPA-SpringData.pdf