🔸 TLDR
JPA abstracts a lot of database complexity.
That convenience can also hide expensive connections, N+1 queries, eager fetching, unnecessary entity loading and transactions that live far longer than expected.
Jos Roseboom's talk is packed with practical reminders.
7️⃣PERFORMANCE LESSONS FROM THE TALK👇
1️⃣ ["it's like five five thousand times faster."]
Connection pooling isn't a tiny optimization. Reusing connections can be orders of magnitude faster than repeatedly creating new database connections.
#ConnectionPooling
2️⃣ ["the amount of connections is finite."]
A pool is fast, but not infinite. Holding connections longer than necessary can make unrelated requests wait and eventually threaten the availability of the whole application.
#HikariCP
3️⃣ ["by default it's fetched eager."]
JPA's default for @ManyToOne and owning-side @OneToOne can surprise you. Associations you never explicitly use may still trigger additional SQL.
#JPA
4️⃣ ["this is an N + 1 problem."]
One query retrieves the main result set, then additional queries are executed as associated entities are accessed. It looks harmless with 10 rows and painful with 10,000.
#NPlusOne
5️⃣ ["If you need it, join fetch it."]
Lazy loading prevents unnecessary work. When an association is genuinely required, explicitly fetching it in the query can avoid the N+1 trap.
#Hibernate
6️⃣ ["a DTO projection is often way superior."]
For read-only use cases, fetching exactly the fields needed by the client can avoid loading full entity graphs and reduce both SQL work and application-side mapping.
#DTO
7️⃣ ["You don't have to use it because you can"]
JPA mappings offer enormous freedom. That doesn't mean every relationship should become a rich entity association. Sometimes mapping a foreign key directly is simpler and faster.
#Persistence
#Java #JPA #Hibernate #SpringBoot #SpringDataJPA #Performance #Database #SQL #BackendDevelopment #JavaPerformance
Go further with Java certification:
Java👇
Spring👇
SpringBook👇
JavaFullstackBook👇