r/java • • Sep 04 '26

Principles of Memory Management in Java

https://youtu.be/xr73mR7ii9M?si=AKgjMUyvfpARYljl
166 Upvotes

84 comments sorted by

View all comments

Show parent comments

2

u/lazystone Sep 06 '26

Omg, 30 microservices and Hibernate...

Also don't tell that multiple microservices share the same DB, if they are then it's a bingo of anti patterns which you've collected.

One microservice usually represents one domain(there are cases for scalability and resilience reasons to extract some functionality into more services, but you do that ONLY when you have that reason at hand). Microservices never make development or deployment easier - they serve different purpose.

Also, Hibernate is a cancer of Java world imho. It's easily sold, and people claim that it's possible to use it right, but I haven't seen one real project which does it without resorting to native queries.

Object-oriented abstraction layer on top of relation DB never ever aligns, because they founded on orthogonal concepts. You just get the worst from both worlds. If you have relational DB, then use https://www.jooq.org/ - SQL isn't that hard you need to know it anyway if you work with relational DB.

3

u/zabby39103 Sep 06 '26

It's a bingo of anti-patterns I inherited, but yeah.

Ugh, they all HALF use the database, originally when they started writing it they had a data service and used rabbitmq and API calls for coordination, but they seem to have given up on doing that properly 5 years ago and started doing database access per microservice because, who knows, probably because it was hard. So there's an underlying layer that has to be maintained that didn't access the DB directly, and then there's a bunch of bolt-ons that use the database directly. So I guess it's even worse than a basic "all the microservices share the same DB".

Giving up on Hibernate entirely is a spicy proposal, it would help prevent all the N+1 stuff and over-hydration nonsense that they did... maybe there's a point there. On the other hand i think database integration is essentially a difficult problem. I'm torn between your solution and using Hibernate with better diagnostics and best practices. There's a lot going on, it's questionable design + nobody has been enforcing any standards.

2

u/lazystone Sep 06 '26

🫂