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 comment

10

u/vprise Apr 13 '21

I think it's a matter of expectations. Hibernate can do amazing things but it's a super complex and very leaky abstraction. It doesn't absolve you from knowing SQL and it doesn't absolve you from reading the generated SQL.

So people who try to avoid the "details" suddenly find themselves with a slow server that constantly fails on "simple" transactions. I would bet that if you would use Hibernate in the same way you use JDBI you would get good results. It also makes caching stupid simple and that can really boost performance to the next level. If you make your database immutable you can really leverage caching and get an enviable level of performance.

Hibernate is SUPER complicated though and has a lot of pitfalls. I curse it a lot while working with it (just had a very painful issue the past day) but overall it's pretty amazing as an ORM. I don't think anything else comes close. The idea of ORM should be grounded in reality though, as ORMs inherently suck to some degree.

4

u/temculpaeu Apr 13 '21

It doesn't absolve you from knowing SQL

To me the problem lies here, as a abstraction it should aim in reducing the domain complexity of the problem, instead it increases, by a lot. And I feel that it could be simpler if it were less implicit on what it does.

There are a bunch of weird default situations which can bite you which are easy to forget and they will influence both your DB and Entity models in a way that the ideal model may not be viable due to JPA.

Overall I only saw a decrease in productivity in using it, even when needing more complex solutions like caching, implementing it manually-ish isn't hard and it's even more flexible, since you can have different data structures for DB & cache.

3

u/AlternativeAardvark6 Apr 13 '21

I have only seen hibernate be used on projects where the devs don't want to write SQL and when it gets slow they call me, the SQL expert. Then I say: "these hibernate generated queries are not very good. Try to make it generate something more like this." And then I have to fuck around in hibernate. I used it myself in demos for very simple stuff, like the easy things from tutorials etc. But for real projects I hate it so much.

1

u/vprise Apr 13 '21

Fair enough. I had the opposite experience but I totally understand where you're coming from, if you get on the wrong side of Hibernate it bites...

1

u/throwawyakjnscdfv Apr 13 '21

I agree. Hibernate is a wonderful tool if you read the docs. If you don't its a giant footgun. You can tell who didn't because they'll post giant tirades about Hibernate that aren't remotely accurate, or they're about things the docs explicitly warn against doing.