Add jdbc-vs-jpa module: Spring Data JDBC vs JPA on a shared Order aggregate
Same Customer/Order/OrderItem domain modelled with Hibernate/Spring Data JPA and Spring Data JDBC side by side, both running through a shared StatementLoggingDataSource so SQL-statement counts are directly comparable. 11 tests, 11 captured transcripts, 6 doc chapters. Companion repo for the ankurm.com article on when to drop the ORM.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
Scenario: findAll() for 3 orders (2 items each), then read .getItems().size()
|
||||
on each in a loop — the pattern that looks completely ordinary in a service
|
||||
method.
|
||||
|
||||
1. select o1_0.id,o1_0.customer_id,o1_0.version from jpa_order o1_0
|
||||
2. select i1_0.order_id,i1_0.id,i1_0.quantity,i1_0.sku from jpa_order_item i1_0 where i1_0.order_id=?
|
||||
3. select i1_0.order_id,i1_0.id,i1_0.quantity,i1_0.sku from jpa_order_item i1_0 where i1_0.order_id=?
|
||||
4. select i1_0.order_id,i1_0.id,i1_0.quantity,i1_0.sku from jpa_order_item i1_0 where i1_0.order_id=?
|
||||
|
||||
total statements: 4
|
||||
|
||||
SELECT statements observed: 4 (1 for the orders themselves + 1 per order for
|
||||
its lazily-loaded items = N+1, here 1 + 3 = 4)
|
||||
Reference in New Issue
Block a user