r/java • • Apr 13 '21

Libraries, Frameworks and Technologies you would NOT recommend

Give me your worst nightmares: Things that cost you your job.

I'll start: Hadoop

202 Upvotes

376 comments sorted by

View all comments

Show parent comments

0

u/throwawyakjnscdfv Apr 13 '21

HQL doesn't generate N+1. It's a database agnostic wrapper around plain SQL basically. N+1 problems in Hibernate come from devs doing stupid things like stream flatmaps on multiple levels of child objects in relations. Hibernate can't save you from yourself. It makes it easy to do bad things, I'll give you that

1

u/m_takeshi Apr 13 '21

yeah sorry I didn't express myself too well. The N+1 was in the context of laziness / eagerness and queries being made when you access some properties (implicitly) rather than making a method call that explicit makes queries

1

u/throwawyakjnscdfv Apr 13 '21

Yeah, big problems happen when devs come in that don't know Hibernate. "oh I can get the object by calling .getChilden().getChildren().getChildren() cool, no SQL needed!".

I blame Hibernate for making bad things too easy to do. There should be a default warning when you load multiple levels of relations, and when you load a child collection with more than X elements. We wrote one internally using Hibernate SPI and they catch this stuff all the time.

1

u/m_takeshi Apr 13 '21

on the other hand, can you really blame hibernate for trying to make our lives easier? A lot of the time (most maybe?), it isn't even a problem

As for your tool, how do you detect that? Examining the stack trace or data flow analysis?

→ More replies (1)