Your SlideShare is downloading. ×
Why Do I Hate Hibernate?
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Why Do I Hate Hibernate?


Published on

Presentation from "Anonymous Developers Club" gathering in Kiev on "ORM" topic

Presentation from "Anonymous Developers Club" gathering in Kiev on "ORM" topic

Published in: Technology

  • I agree and I'd like to add two other issues. The first one is that Hibernate generates Proxy Classes that consumes lots of memory (-XX:MaxPermSize) on large projects crashing the server: its fine for 'Hello World'. The second one is that Lazy strategy is useless for service oriented projects like a Rest API because serialization causes all getters to be invoked.
    Are you sure you want to  Yes  No
    Your message goes here
  • Many people are completely unaware of possibility of deadlocks in database and are unaware about the fact, that hibernate don't offer instruments to control locking order. We struggled this problem in production and found no solution other than doing explicit Session.flush to ensure query ordering. That a shame.
    Are you sure you want to  Yes  No
    Your message goes here
  • It turns out, that grandma is smarter than many of today's programmers. I also didn't know about slide #7. Thanks you, Mikalai, cool speech, especially in the end of conference!
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Why Do I Hate Hibernate?
    Mikalai Alimenkou
  • 2. Nobody understand how equals and hashCode must look like
    • There is no common solution
    • 3. It is hard decision when there is no “unique business key” for the entity
    • 4. Many issues with inclusion of child collections in calculation
  • Mutable objects are evil
    • Default constructor must present
    • 5. Fields can’t be final
    • 6. State of object may become inconsistent
    • 7. Or… reflection magic will happen
  • DTO is evil pattern with Hibernate
    • Lots of code duplication
    • 8. Hard to maintain if many entities exists
    • 9. No simple and common pattern implementation
    • 10. Silent DTO mapping errors
    • 11. With large object tree it is like hell
  • Criteria API or HQL?
    • Some simple things are missed in Criteria API (for example, filtering by collection of elements)
    • 12. Mixing HQL and Criteria API looks strange
    • 13. Criteria API is designed for dynamic queries, but not HQL
  • To update single field you should read full entity
    • Child collections retrieved as well or made lazy
    • 14. Few people understand in details how lazy loading works
    • 15. At least 2 SQL queries to update single field
    • 16. This pattern makes developers stupid
  • Parent records are copied to temporary table on update or delete
  • 17. Entity state can be managed only from one side in parent-child relationship
  • 18. Flush on commit is too unpredictable
    • Entity can’t be changed to avoid DB update
    • 19. Child collections must be copied before modification
    • 20. Constraint exception handling code may be missed at all
    • 21. No control of queries ordering that may cause deadlocks
  • Documentation is simple but primitive
    • Only basic samples are covered
    • 22. For all complex things you need to consult with books (“Java Persistence with Hibernate” is the best)
    • 23. Bug reports are ignored by development team
  • Hibernate makes developers stupid
    • Many of them don’t know JDBC at all
    • 24. Few people go deeper than simple mapping
    • 25. Almost nobody count number of SQL queries performed and their structure
    • 26. Very few people know how to tune Hibernate via JDBC parameters
  • Any questions?