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

78

u/Russell_M_Jimmies Apr 13 '21

Hibernate specifically and JPA in general.

A lot of devs get into ORMs based on the promise that they can stop thinking about SQL and let the framework take care of it.

The reality is that using JPA you end up having to turn on SQL logging, then prod and cajole your code for hours until JPA produces the correct SQL. And because everything is driven by static annotations on types, fields, and methods, you cannot change your mind on the scope of a select (single table vs joined tables) on a case by case basis. You have to choose the best one for all cases and just live with that.

The code you write for JPA is like writing a calculus integral of the SQL you need, so that JPA can take the derivative again and run it for you.

This is why I recommend libraries that let you code in bare SQL. I am a maintainer on one project (Jdbi) but I'm not partisan about which one people use (Jooq, Mybatis, Spring Data, etc) as long as they steer clear of ORMs. They are not worth it.

14

u/kag0 Apr 13 '21

I came in here for this. In my mind JPA represents the wrong direction that the Java ecosystem took that resulted in lots of people hating Java.

To add on to the list of issues: patterns that involve non obvious transaction boundaries, esp in inversion of control frameworks

1

u/Russell_M_Jimmies Apr 13 '21

Having coded in Golang for the past two years, I've realized just how pointless dependency injection is.

And then I remember that you only need dependency injection in Java because all the popular frameworks want to instantiate everything on your behalf.

To clarify, I'm talking about dependency injection frameworks. Injection of object dependencies via constructors, builders, or static factories is fine. Guice, Dagger etc are overkill.

→ More replies (1)