• Save
Why Do I Hate Hibernate?
Upcoming SlideShare
Loading in...5
×
 

Why Do I Hate Hibernate?

on

  • 5,104 views

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

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

Statistics

Views

Total Views
5,104
Views on SlideShare
4,339
Embed Views
765

Actions

Likes
2
Downloads
0
Comments
3

3 Embeds 765

http://xpinjection.com 757
http://www.linkedin.com 5
http://www.google.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • 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
    Your message goes here
    Processing…
  • 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
    Your message goes here
    Processing…
  • 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
    Your message goes here
    Processing…
Post Comment
Edit your comment

Why Do I Hate Hibernate? Why Do I Hate Hibernate? Presentation Transcript

  • Why Do I Hate Hibernate?
    Mikalai Alimenkou
    http://xpinjection.com
    13.09.2011
  • Nobody understand how equals and hashCode must look like
    • There is no common solution
    • It is hard decision when there is no “unique business key” for the entity
    • Many issues with inclusion of child collections in calculation
  • Mutable objects are evil
    • Default constructor must present
    • Fields can’t be final
    • State of object may become inconsistent
    • Or… reflection magic will happen
  • DTO is evil pattern with Hibernate
    • Lots of code duplication
    • Hard to maintain if many entities exists
    • No simple and common pattern implementation
    • Silent DTO mapping errors
    • 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)
    • Mixing HQL and Criteria API looks strange
    • 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
    • Few people understand in details how lazy loading works
    • At least 2 SQL queries to update single field
    • This pattern makes developers stupid
  • Parent records are copied to temporary table on update or delete
  • Entity state can be managed only from one side in parent-child relationship
  • Flush on commit is too unpredictable
    • Entity can’t be changed to avoid DB update
    • Child collections must be copied before modification
    • Constraint exception handling code may be missed at all
    • No control of queries ordering that may cause deadlocks
  • Documentation is simple but primitive
    • Only basic samples are covered
    • For all complex things you need to consult with books (“Java Persistence with Hibernate” is the best)
    • Bug reports are ignored by development team
  • Hibernate makes developers stupid
    • Many of them don’t know JDBC at all
    • Few people go deeper than simple mapping
    • Almost nobody count number of SQL queries performed and their structure
    • Very few people know how to tune Hibernate via JDBC parameters
  • Any questions?