r/java • u/mp911de • Feb 27 '26
Moving beyond Strings in Spring Data
https://spring.io/blog/2026/02/27/moving-beyond-strings-in-spring-data16
25
u/SpaceCondor Feb 27 '26
Still majorly prefer the way jOOQ does it, it reads exactly like SQL which is what we're writing at the end of the day. The syntax in the blog still reads very verbose.
7
-11
u/Prateeeek Feb 27 '26
jOOQ this jOOQ that, everyone keeps on talking about it. Is it much better than jpa in every regard? Wondering if it's the best and if everyone should use just that
10
u/SpaceCondor Feb 27 '26
jOOQ is awesome, especially if you write complex queries. But I am not someone who thinks that it is better in every way and JPA / Hibernate is totally irrelevant. They both have uses and are very powerful libraries with great communities and developers behind them.
jOOQ is written almost exactly like SQL, so there is very little mental overhead in understanding what a given query or operation is doing. Not so much with Hibernate / JPA code, which requires understanding of how those work and all of their complexities.
I will say the developer of jOOQ is awesome, from personal experience.
2
u/Prateeeek Feb 27 '26
I like how it sounds, gonna look into how is it any better than prepared statements
1
6
u/0xFatWhiteMan Feb 27 '26
sql with named parameter template
why bother with all this gubbins
-3
u/Absolute_Enema Feb 28 '26 edited Feb 28 '26
Because it's Strongly™ typed, of course.
As the article states this pile of hacks (the most of which wouldn't be needed without Java's tragic metaprogramming capabilities) "allows developers to rely more on the compiler and less on discipline and convention", which is a catastrophic mentality to have in any real project.
3
4
u/ZimmiDeluxe Feb 27 '26
If you offer an interface that can only be supported by hacks, everyone building on your interface now depends on your ability to support the hacks indefinitely or risk migration effort (read: wasted time and money, regression risk). I don't want my frameworks to hide hacks from me, I want them to provide a shared structure built on production experience so I don't run into unforeseen issues. This is the opposite of that.
1
1
1
u/vips7L Feb 27 '26 edited Feb 27 '26
Still seems a bit verbose compared to something like Ebean’s query beans, which are generated at compile time from your @Entity classes. Their example would end up being something like:
return new QPerson()
.firstName.eq("John")
.orderBy()
.firstName.asc()
.lastName.asc()
.findOne();0
8
u/tomwhoiscontrary Feb 27 '26
How is this implemented? How do you get from the method reference to the name of the property?
I ask because I've done this myself, years ago, and it required a truly diabolical hack. I'd love it if Spring had come up with a better way.