Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Make sure you evaluate the DataNucleus implementation of JDO. We started out with Hibernate because it appeared to be so popular but pretty soon realized that it's not a 100% transparent persistence solution. There are too many caveats and the documentation is full of 'if you have this situation then you must write your code like this' that took away the fun of freely modeling and coding however we want. JDO has <em>never</em> caused me to adjust my code or my model to get it to 'work properly'. I can just design and code simple POJOs as if I was going to use them 'in memory' only, yet I can persist them transparently.</p> <p>The other advantage of JDO/DataNucleus over hibernate is that it doesn't have all the run time reflection overhead and is more memory efficient because it uses build time byte code enhancement (maybe add 1 sec to your build time for a large project) rather than hibernate's run time reflection powered proxy pattern.</p> <p>Another thing you might find annoying with Hibernate is that a reference you have to what you think is the object... it's often a 'proxy' for the object. Without the benefit of byte code enhancement the proxy pattern is required to allow on demand loading (i.e. avoid pulling in your entire object graph when you pull in a top level object). Be prepared to override equals and hashcode because the object you think you're referencing is often just a proxy for that object. </p> <p>Here's an example of frustrations you'll get with Hibernate that you won't get with JDO:</p> <p><a href="http://blog.andrewbeacock.com/2008/08/how-to-implement-hibernate-safe-equals.html" rel="nofollow noreferrer">http://blog.andrewbeacock.com/2008/08/how-to-implement-hibernate-safe-equals.html</a><br> <a href="http://burtbeckwith.com/blog/?p=53" rel="nofollow noreferrer">http://burtbeckwith.com/blog/?p=53</a></p> <p>If you like coding to 'workarounds' then, sure, Hibernate is for you. If you appreciate clean, pure, object oriented, model driven development where you spend all your time on modeling, design and coding and none of it on ugly workarounds then spend a few hours evaluating <a href="http://www.datanucleus.org" rel="nofollow noreferrer">JDO/DataNucleus</a>. The hours invested will be repaid a thousand fold.</p> <h2>Update Feb 2017</h2> <p>For quite some time now DataNucleus' implements the JPA persistence standard in addition to the JDO persistence standard so porting existing JPA projects from Hibernate to DataNucleus should be very straight forward and you can get all of the above mentioned benefits of DataNucleus with very little code change, if any. So in terms of the question, the choice of a particular standard, JPA (RDBMS only) vs JDO (RDBMS + No SQL + ODBMSes + others), DataNucleus supports both, Hibernate is restricted to JPA only.</p> <h2>Performance of Hibernate DB updates</h2> <p>Another issue to consider when choosing an ORM is the efficiency of its dirty checking mechanism - that becomes very important when it needs to construct the SQL to update the objects that have changed in the current transaction - especially when there are a lot of objects. There is a detailed technical description of Hibernate's dirty checking mechanism in this SO answer: <a href="https://stackoverflow.com/questions/19983065/jpa-with-hibernate-insert-very-slow/42212442#42212442">JPA with HIBERNATE insert very slow</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload