r/SpringBoot • u/Final-Drop-1935 Senior Dev • Jul 25 '26
News I asked Java Champion Vlad Mihalcea about ORM vs SQL in the AI era, and Spring Data JDBC vs Spring Data JPA
I recently interviewed Vlad Mihalcea, a Java Champion and long-time Hibernate ORM contributor, for the Korean developer community. Two persistence questions stood out.
1. If AI can generate SQL, do we still need ORM?
Plain JDBC still requires SQL execution, result processing, and mapping code to write and maintain. AI can now generate much of that work.
Vlad agreed that this changes the trade-off. If a team is comfortable with SQL and wants a lightweight stack, plain JDBC with AI handling some of the boilerplate can be a practical combination.
But his point was that JPA/Hibernate is not merely a way to avoid writing SQL. It also provides facilities that teams would otherwise need to manage more explicitly:
- standardized optimistic and pessimistic locking support
- configurable JDBC statement batching
- inheritance mapping
- persistence context / first-level cache
- association-loading strategies
Vlad’s point was that these patterns have been implemented and tested in real projects for roughly two decades.
If an application does not need them, plain JDBC with AI can be perfectly reasonable. If it does, the team may have to implement or manage the same behavior itself after replacing Hibernate.
2. Spring Data JDBC vs Spring Data JPA
Spring Data JDBC can look like a lighter alternative to Spring Data JPA, but lighter does not automatically mean faster.
Spring Data JDBC has no lazy loading. When a repository loads an aggregate, it also loads the mapped child entities and collections within that aggregate boundary. Without inspecting the actual SQL, a team can still fetch more data than expected.
If the real problem is the shape of the queries or the aggregate design, switching persistence libraries will not fix it by itself.
Vlad also tied this decision to the team’s existing skills:
- A team strong in SQL and database performance may do very well with JDBC or jOOQ.
- A team that has used Spring Data JPA successfully for years may gain little from switching simply because another option is trending.
- Technologies with abundant public documentation and examples are also more likely to yield useful AI answers.
Across both answers, I heard the same criterion: choose a persistence model your team can understand, verify, and operate well. Do not choose based on trends alone.
Full interview, for context (free):
https://www.inflearn.com/en/course/vlad-mihalcea-interview
Disclosure: I work at Inflearn, which hosts the interview.
Has AI changed what your team uses in production, or only how quickly you implement it?
12
u/Necessary_Apple_5567 Jul 25 '26
Again and again. You don’t need to load aggregate. You don’t need to keep this monster aggregate object in memory. The idea of keeping the aggregate/ model object in memory was born in EJB Entity objects and supposed to be dead together with entity beans. We always know what kind of data we need to complete api call and can prepare highly optimised query for that. It saves tonns of time later.
6
u/Intrepid_Fox5414 Jul 25 '26
Mastering SQL is the way to go
11
u/Paw565 Jul 25 '26
Jooq ftw
2
u/verdant-amiable Jul 25 '26 edited Jul 25 '26
The main thing I dislike about JDBC mapping is it's pretty fragile. Like it's too easy to accidentally write an edge case where it triggers an exception during mapping, but hibernate/JPA tends to create relatively robust mappings by default, and it always creates complete mappings with respect to your entity definition.
edit: should also mention SB's DataClassRowMapper as a middle ground for safe mapping if you're willing to swallow a bit of a reflection performance hit.
In the context of LLMs this is nice and is consistent with the best practice of giving the LLMs sensible constraints rather than letting them just fully vibe code things.
1
u/Agile_Rain4486 Jul 25 '26
1. If AI can generate SQL, do we still need ORM?
what kind of dumb ... question is this? I would rather not speak anything than asking such question.
1
u/Ok_Marionberry_8821 Jul 25 '26
I'm perfectly happy using AI to help write vanilla SQL queries and junit test cases, via JDBC. JPA always smelt off to me, too clever by far, a leaky abstraction - just learn SQL. For a while I dabbled with jOOQ but with AI I can have efficient queries written in a jiffy. Queries I can easily paste into dbeaver to test things out. I'll admit that my use cases suits vanilla SQL, even if some of the views are heavily recursive aggregations.
1
u/JavaProgrammer7777 Jul 25 '26
Off topic: I know who Vlad is, but I found it funny how google tells me that he's a soccer player when I look him up hahaha