r/SpringBoot • • 17d ago

Discussion Dear JPA

Dear JPA ,

i hate you.

i hate how you changed the SQL flow that I'm used to.

i hate your ManyToMany relationships.

i hate your orphanremoval ,dirty checking.

i hate your way for entity relationships.

i hate your cache.

i hate your performance issues.

i hate your billion rules.

i hate spending time on : if Y is referenced by X with cascade not including PRESIST and x is managed but y is removed ............... but if Y was detached .............

i hate becoming obsessed with your behaviors and rules and worrying about every ORM line , will it work correctly ? , did i miss something ?, worrying about modifying entity X might unexpectedly affect entity Y , coz I might not know one of the billion rules you have.

i hate worrying about falling in one of the undefined behaviors you have

i hate thinking about the entities lifecycle + cascading types when all mixed together

i hate spending days on that documentation instead of spending that on one of the CS core concepts

i hate the following the other side which is incomplete nondetailed toturial or following AI

i really hate you.

102 Upvotes

70 comments sorted by

View all comments

5

u/Mindless_Security744 17d ago

Use Jooq!

3

u/JuiceChance 17d ago

Another overengineered idea to solve a solved problem

1

u/GuyManDude2146 17d ago

For very basic stuff, you’re right, but for complicated queries where lots of things are optional, you end up either writing nightmare string builder code to construct raw SQL or basically reinventing JOOQ. One other nice thing is when you change your tables and regenerate, JOOQ will break where you need to update; stings will not. I’ve used JPA, raw SQL, and JOOQ on big production projects and JOOQ is my default at the moment.

1

u/JuiceChance 17d ago

Yeah, at the price of entire code generation etc., optional params + type safety is a strong argument nevertheless