Search code examples
hibernatejpaibatiseclipselinktoplink

Pitfalls and practical Use-Cases: Toplink, Hibernate, Eclipse Link, Ibatis


I worked a lot with Hibernate as my JPA implementation. In most cases it works fine! But I have also seen a lot of pitfalls:

  • Remoting with persisted Objects is difficult, because Hibernate replaces the Java collections with its own collection implementation. So the every client must have the Hibernate .jar libraries. You have to take care on LazyLoading exceptions etc. One way to get around this problem is the use of webservices.
  • Dirty checking is done against the Database without any lock.
  • "Delayed SQL", causes that the data access isn't ACID compliant. (Lost data...)
  • Implict Updates >> So we don't know if an object is modified or not (commit causes updates).

Are there similar issues with Toplink, Eclipse Link and Ibatis? When should I use them? Have they a similar performance? Are there reasons to choose Eclipse Link/Toplink... over Hibernate?


Solution

  • I can share my fair amount of Hibernate pitfalls:

    • Criteria API is not typesafe
    • Criteria API is relatively bad designed (ex: you cannot retrieve the current aliases)
    • If you create an alias, you are forcing a inner join (this is in the docs but is misleading)
    • No support for UNIONs
    • No easy way to 'de-proxy' a persistent object (remoting is supported by third parties)
    • No support for tables without PKs (I now it's dumb but it happens in legacy schemas)
    • No easy way to use sequences for non-PK columns (not so dumb)

    As for most JPA implementations, I always found that I'd have to rely on some custom annotations or so to do stuff that it is not covered in the JPA spec.