Why do I hate Hibernate?       Mikalai Alimenkou     http://xpinjection.com           19.05.2012
CRUD*R – read by ID
Why Hibernate is so popular?                   1. EJB 2 sucks!                           +                2. New “standard”
WTF #1. Nobody understand howequals and hashCode must look like
Comparison context is                           very important  Hard to select real“unique business key”Performance issues...
WTF #2. Mutable objects are evil
Default constructor                         must present Fields can’t   be finalInconsistent object  state is possibleOr… ...
POJO bullshit   game
WTF #3. DTO is evil patternwith Hibernate
Lots of code      DTO maintenance  duplications        is nightmare  Many solutions:  - transformers     - beanutils    - ...
WTF #4. Lazy loading
Nightmare for       Everything is stupidly newcomers             slow without it  Almost nobody  understand how     it wor...
WTF #5. Criteria API or HQL?                  =
WTF?!?No need to know    SQL???   Bullshit!!!
Different features set in                      HQL and Criteria API  Hand made query   builders in HQL   No check for   NU...
WTF #6. To update single fieldyou should read full entity
Children and large Not everybody                      fields are loadedunderstand how  ‘lazy loading’      works HQL updat...
WTF #7. Temporary table usageon update or delete
WTF #8. Composite key requiresseparate class
WTF #9. Entity state can be managedonly from one side in parent-childrelationship
WTF #10. Flush on commit istoo unpredictable
Entity changes are                               persisted      Collections  operations are ‘live’  Constraints arechecked...
WTF #11. Dirty entity aftertransaction rollback can’t be reused
WTF #12. Documentation issimple but primitive
Only basic samples  For complex           are coveredthings you need     books   Bug reports are      ignored Debug hell t...
WTF #13. Hibernate makesdevelopers stupid   Are you  joking???
People don’t learn                     JDBC and SQL Nobody countSQL queries andcare about their   structure  Developersdon...
When we really need to use ORM?
Is CQRS more actual now?
Useful books
@xpinjection             http://xpinjection.commikalai.alimenkou@xpinjection.com
Why do I hate Hibernate?
Upcoming SlideShare
Loading in...5
×

Why do I hate Hibernate?

17,380

Published on

Presentation from JEEConf conference (Kiev, May 2012) about issues in Hibernate usage and tricks to avoid them.

Published in: Technology
2 Comments
16 Likes
Statistics
Notes
  • 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.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • True history! congrats
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
17,380
On Slideshare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
0
Comments
2
Likes
16
Embeds 0
No embeds

No notes for slide

Transcript of "Why do I hate Hibernate?"

  1. 1. Why do I hate Hibernate? Mikalai Alimenkou http://xpinjection.com 19.05.2012
  2. 2. CRUD*R – read by ID
  3. 3. Why Hibernate is so popular? 1. EJB 2 sucks! + 2. New “standard”
  4. 4. WTF #1. Nobody understand howequals and hashCode must look like
  5. 5. Comparison context is very important Hard to select real“unique business key”Performance issues with collections Auto-generated fields in Set
  6. 6. WTF #2. Mutable objects are evil
  7. 7. Default constructor must present Fields can’t be finalInconsistent object state is possibleOr… reflectionmagic happens
  8. 8. POJO bullshit game
  9. 9. WTF #3. DTO is evil patternwith Hibernate
  10. 10. Lots of code DTO maintenance duplications is nightmare Many solutions: - transformers - beanutils - reflection - librariesCrazy DTO “don’tforget” checklist
  11. 11. WTF #4. Lazy loading
  12. 12. Nightmare for Everything is stupidly newcomers slow without it Almost nobody understand how it works Persistent collections are not serializable
  13. 13. WTF #5. Criteria API or HQL? =
  14. 14. WTF?!?No need to know SQL??? Bullshit!!!
  15. 15. Different features set in HQL and Criteria API Hand made query builders in HQL No check for NULL in HQLCriteria API only for READ
  16. 16. WTF #6. To update single fieldyou should read full entity
  17. 17. Children and large Not everybody fields are loadedunderstand how ‘lazy loading’ works HQL update is not object-oriented At least 2 SQL queries for simple update
  18. 18. WTF #7. Temporary table usageon update or delete
  19. 19. WTF #8. Composite key requiresseparate class
  20. 20. WTF #9. Entity state can be managedonly from one side in parent-childrelationship
  21. 21. WTF #10. Flush on commit istoo unpredictable
  22. 22. Entity changes are persisted Collections operations are ‘live’ Constraints arechecked on commitNo control for SQL queries order
  23. 23. WTF #11. Dirty entity aftertransaction rollback can’t be reused
  24. 24. WTF #12. Documentation issimple but primitive
  25. 25. Only basic samples For complex are coveredthings you need books Bug reports are ignored Debug hell tounderstand how things work
  26. 26. WTF #13. Hibernate makesdevelopers stupid Are you joking???
  27. 27. People don’t learn JDBC and SQL Nobody countSQL queries andcare about their structure Developersdon’t tune JDBC properties
  28. 28. When we really need to use ORM?
  29. 29. Is CQRS more actual now?
  30. 30. Useful books
  31. 31. @xpinjection http://xpinjection.commikalai.alimenkou@xpinjection.com

×