<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Hibernate has Problems, but where is the Alternative?</title>
	<atom:link href="http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/</link>
	<description>Softwaredevelopment, Projectmanagement, Qualitymanagement and all things &#34;schauderhaft&#34;</description>
	<lastBuildDate>Thu, 02 Sep 2010 08:13:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Rob Bygrave</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-296</link>
		<dc:creator>Rob Bygrave</dc:creator>
		<pubDate>Thu, 29 Oct 2009 10:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-296</guid>
		<description>Some of these points you have raised have already been addressed in existing ORM&#039;s like Ebean ORM. (http://www.avaje.org)


- LazyInitializationExceptions 
---------------------------------------
Other ORM&#039;s including Ebean ORM don&#039;t throw a LazyInitializationExceptions. That&#039;s a Hibernate specific approach.


- The management of Sessions ...
--------------------------------------------
Some ORM&#039;s are design/architected to be &quot;session less&quot;. 

Ebean ORM for example doesn&#039;t have an object equivilent to the Hibernate session or JPA EntityManager. Another way of saying this is that Ebean ORM provides &quot;automatic management of the persistence context&quot; - which is what you seemed to alude to. 

As you probably know, the point of that is to remove the need to manage the &quot;session&quot; objects which makes life easier much for the developer.

Aka ORM session objects (like Hibernate Session / JPA EntityManager) are an architectural design decision and not required/used by some existing ORM&#039;s today. 



- ORMs will monitor how they are used for a certain application, and will use that information to improve the SQL used.
--------------------------------------------------------
&quot;Autofetch&quot; defines exactly this behaviour. The application is profiled and from this information the ORM can automatically tune the queries fetching only the properties required.  

Ebean ORM has had this feature for about 1 1/2 years. Works very nicely with Ebean&#039;s &quot;partial object&quot; support (which is mostly absent from JPA).

Refer to: 
http://www.cs.utexas.edu/~aibrahim/autofetch/
http://www.avaje.org/autofetch.html</description>
		<content:encoded><![CDATA[<p>Some of these points you have raised have already been addressed in existing ORM&#8217;s like Ebean ORM. (<a href="http://www.avaje.org">http://www.avaje.org</a>)</p>
<p>- LazyInitializationExceptions<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Other ORM&#8217;s including Ebean ORM don&#8217;t throw a LazyInitializationExceptions. That&#8217;s a Hibernate specific approach.</p>
<p>- The management of Sessions &#8230;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Some ORM&#8217;s are design/architected to be &#8220;session less&#8221;. </p>
<p>Ebean ORM for example doesn&#8217;t have an object equivilent to the Hibernate session or JPA EntityManager. Another way of saying this is that Ebean ORM provides &#8220;automatic management of the persistence context&#8221; &#8211; which is what you seemed to alude to. </p>
<p>As you probably know, the point of that is to remove the need to manage the &#8220;session&#8221; objects which makes life easier much for the developer.</p>
<p>Aka ORM session objects (like Hibernate Session / JPA EntityManager) are an architectural design decision and not required/used by some existing ORM&#8217;s today. </p>
<p>- ORMs will monitor how they are used for a certain application, and will use that information to improve the SQL used.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8220;Autofetch&#8221; defines exactly this behaviour. The application is profiled and from this information the ORM can automatically tune the queries fetching only the properties required.  </p>
<p>Ebean ORM has had this feature for about 1 1/2 years. Works very nicely with Ebean&#8217;s &#8220;partial object&#8221; support (which is mostly absent from JPA).</p>
<p>Refer to:<br />
<a href="http://www.cs.utexas.edu/~aibrahim/autofetch/">http://www.cs.utexas.edu/~aibrahim/autofetch/</a><br />
<a href="http://www.avaje.org/autofetch.html">http://www.avaje.org/autofetch.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blog harvest, October II &#171; Schneide Blog</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-292</link>
		<dc:creator>Blog harvest, October II &#171; Schneide Blog</dc:creator>
		<pubDate>Sun, 25 Oct 2009 19:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-292</guid>
		<description>[...] ORMs are a thing of the past &#8211; Another opinion that might get in the way of hibernate fanboys. We&#8217;ve had our share of hibernate &#8220;experiences&#8221;. It&#8217;s a useful tool if you know how to use it &#8211; and when not to. Replies followed instantly, here are two noteworthy ones by Scot Mcphee and by Jens Schauder. [...]</description>
		<content:encoded><![CDATA[<p>[...] ORMs are a thing of the past &#8211; Another opinion that might get in the way of hibernate fanboys. We&#8217;ve had our share of hibernate &#8220;experiences&#8221;. It&#8217;s a useful tool if you know how to use it &#8211; and when not to. Replies followed instantly, here are two noteworthy ones by Scot Mcphee and by Jens Schauder. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vic</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-290</link>
		<dc:creator>Vic</dc:creator>
		<pubDate>Wed, 21 Oct 2009 03:06:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-290</guid>
		<description>Apache iBatis.</description>
		<content:encoded><![CDATA[<p>Apache iBatis.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Schauder</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-289</link>
		<dc:creator>Jens Schauder</dc:creator>
		<pubDate>Tue, 20 Oct 2009 21:55:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-289</guid>
		<description>Thanks everybody for the comments. (and for the votes on dzone)

A couple of comments to various points:

- I know how to get hibernate the Eager/Lazy loading I need. What I complain about is that in doing so, I annotate domain model with stuff that really belongs in the persistence layer.

- Lazy Initialization Exception: You are probably right about the frameworks. I used Hibernate in a two tier application. Session handling is much less explored in &lt;a href=&quot;/2007/12/17/hibernate-sessions-in-fat-client-anwendungen/&quot;  rel=&quot;nofollow&quot;&gt;this case&lt;/a &gt;

- I don&#039;t think persistence annotations on domain classes are a &#039;subjective&#039; matter. But I do agree that they are better then XML. And I only have a rough idea, how it could be done in a &lt;a href=&quot;/2009/08/16/high-level-frameworks/&quot;  rel=&quot;nofollow&quot;&gt;cleaner way&lt;/a&gt;.

- I looked at some of the simpler frameworks like ibatis. Its not a direction I want to go.

And since I get the feeling at some got it the other way round: I do like hibernate and will probably use it in the next projects. But I do see room for improvement. Would be strange otherwise, wouldn&#039;t it?</description>
		<content:encoded><![CDATA[<p>Thanks everybody for the comments. (and for the votes on dzone)</p>
<p>A couple of comments to various points:</p>
<p>- I know how to get hibernate the Eager/Lazy loading I need. What I complain about is that in doing so, I annotate domain model with stuff that really belongs in the persistence layer.</p>
<p>- Lazy Initialization Exception: You are probably right about the frameworks. I used Hibernate in a two tier application. Session handling is much less explored in <a href="/2007/12/17/hibernate-sessions-in-fat-client-anwendungen/" >this case</a></p>
<p>- I don&#8217;t think persistence annotations on domain classes are a &#8216;subjective&#8217; matter. But I do agree that they are better then XML. And I only have a rough idea, how it could be done in a <a href="/2009/08/16/high-level-frameworks/" >cleaner way</a>.</p>
<p>- I looked at some of the simpler frameworks like ibatis. Its not a direction I want to go.</p>
<p>And since I get the feeling at some got it the other way round: I do like hibernate and will probably use it in the next projects. But I do see room for improvement. Would be strange otherwise, wouldn&#8217;t it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sanne</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-288</link>
		<dc:creator>Sanne</dc:creator>
		<pubDate>Tue, 20 Oct 2009 21:02:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-288</guid>
		<description>as Emmanuel said already, no more lazy initializations using the proper framework; If I see one, I know someone is doing dirty code or the configuration is wrong.
I&#039;d add that also the Sessions are now declaratively scoped, it really comes up in updating the frameworks people are using.
About &quot;1:M relation is ‘big’.&quot; that&#039;s also a thing from the past, you can get the behaviour you want, annotating properly. Sure, as a developer you have to know what you&#039;re asking for.

About the generated SQL, I might be not a DB expert but I&#039;ve learnt a lot from the generated SQL, when you test it out it&#039;s often better than what I would have written. That doesn&#039;t mean it&#039;s approaching perfection, but is far from wrong and much better than the average developer.

I really agree with the conclusion; it&#039;s since 3 years know that I lead succesfull project in which the goal is to create a good domain model first, and then have Hibernate generate an appropriate schema. If the schema doesn&#039;t look right, we go back to the model and see what we are doing wrong. It&#039;s more a kind of feedback/validation than the starting point. So definitely Hibernate is maturing, even if many new features are coming, but most people can&#039;t - or don&#039;t want - get the best out of it.

btw, I&#039;ve experienced ibatis: it might be simple, but far from the usefulness, too much work to get stuff working.

Annotations might not be heaven, but are by far the most practical option available.</description>
		<content:encoded><![CDATA[<p>as Emmanuel said already, no more lazy initializations using the proper framework; If I see one, I know someone is doing dirty code or the configuration is wrong.<br />
I&#8217;d add that also the Sessions are now declaratively scoped, it really comes up in updating the frameworks people are using.<br />
About &#8220;1:M relation is ‘big’.&#8221; that&#8217;s also a thing from the past, you can get the behaviour you want, annotating properly. Sure, as a developer you have to know what you&#8217;re asking for.</p>
<p>About the generated SQL, I might be not a DB expert but I&#8217;ve learnt a lot from the generated SQL, when you test it out it&#8217;s often better than what I would have written. That doesn&#8217;t mean it&#8217;s approaching perfection, but is far from wrong and much better than the average developer.</p>
<p>I really agree with the conclusion; it&#8217;s since 3 years know that I lead succesfull project in which the goal is to create a good domain model first, and then have Hibernate generate an appropriate schema. If the schema doesn&#8217;t look right, we go back to the model and see what we are doing wrong. It&#8217;s more a kind of feedback/validation than the starting point. So definitely Hibernate is maturing, even if many new features are coming, but most people can&#8217;t &#8211; or don&#8217;t want &#8211; get the best out of it.</p>
<p>btw, I&#8217;ve experienced ibatis: it might be simple, but far from the usefulness, too much work to get stuff working.</p>
<p>Annotations might not be heaven, but are by far the most practical option available.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-287</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 20 Oct 2009 11:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-287</guid>
		<description>Another lightweight solution: 
 &lt;a href=&quot;http://ujoframework.org/presentation/&quot; title=&quot;Ujorm&quot; rel=&quot;nofollow&quot;&gt;http://ujoframework.org/presentation/&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Another lightweight solution:<br />
 <a href="http://ujoframework.org/presentation/" title="Ujorm">http://ujoframework.org/presentation/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stanasic</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-285</link>
		<dc:creator>stanasic</dc:creator>
		<pubDate>Tue, 20 Oct 2009 08:29:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-285</guid>
		<description>I am by no means a Hibernate fan boy, but those points in which you agree with Stephen are pretty weak in my opinion. Let me clarify:

&lt;cite&gt;
- The SQL generated by Hibernate by default is horrible. Huge joins, with hundreds of columns, many unneeded.
&lt;/cite&gt;

I think most of the SQL Hibernate generates is fine. In most of the cases, even if it appears bulky, there is no performance hit when it is actually executed by database. If you feel you&#039;re selecting more columns than you need,  maybe you need more fine-grained objects in your domain model. If there are too many joins, you are probably using too much EAGER fetching.

Furthermore, you can use custom (native) SQL and still populate the domain objects, if you feel like it.

&lt;cite&gt;
- Annotations feel like dirt in your code, and maintaining XML mappings is just painful.
&lt;/cite&gt;

This is &lt;b&gt;extremely&lt;/b&gt; subjective. I like having annotations in domain classes, since persistence is a key feature of those objects. You can minimize the amount of them by using proper NamingStrategy, so Hibernate can deduce column, table, foreign key names without you specifying them directly.

And the cost of maintaining XML mappings has been blown way out of proportion. Some of the info contained therein can be deduced either from Java side or from the database, but still, how often do you refactor your domain classes and/or database from the ground up? Someone without prior exposure to Hibernate would think there is some kind of magic involved with mapping files, but, in reality, they are quite readable and editable.

&lt;cite&gt;
- LazyInitializationExceptions are a pain in the a.. neck.
&lt;/cite&gt;

They are no more pain in the neck than, say, NullPonterExceptions. They simply signify the data you ask has not been loaded from database. What would you expect Hibernate to do. If the data is not there, you can either:

1) make sure you fetch it, before you operate on it
2) leave the session open, so Hibernate will do that for you (say, by means of OpenSessionInViewFilter)

Lastly, I wholeheartedly agree with your last paragraph.</description>
		<content:encoded><![CDATA[<p>I am by no means a Hibernate fan boy, but those points in which you agree with Stephen are pretty weak in my opinion. Let me clarify:</p>
<p><cite><br />
- The SQL generated by Hibernate by default is horrible. Huge joins, with hundreds of columns, many unneeded.<br />
</cite></p>
<p>I think most of the SQL Hibernate generates is fine. In most of the cases, even if it appears bulky, there is no performance hit when it is actually executed by database. If you feel you&#8217;re selecting more columns than you need,  maybe you need more fine-grained objects in your domain model. If there are too many joins, you are probably using too much EAGER fetching.</p>
<p>Furthermore, you can use custom (native) SQL and still populate the domain objects, if you feel like it.</p>
<p><cite><br />
- Annotations feel like dirt in your code, and maintaining XML mappings is just painful.<br />
</cite></p>
<p>This is <b>extremely</b> subjective. I like having annotations in domain classes, since persistence is a key feature of those objects. You can minimize the amount of them by using proper NamingStrategy, so Hibernate can deduce column, table, foreign key names without you specifying them directly.</p>
<p>And the cost of maintaining XML mappings has been blown way out of proportion. Some of the info contained therein can be deduced either from Java side or from the database, but still, how often do you refactor your domain classes and/or database from the ground up? Someone without prior exposure to Hibernate would think there is some kind of magic involved with mapping files, but, in reality, they are quite readable and editable.</p>
<p><cite><br />
- LazyInitializationExceptions are a pain in the a.. neck.<br />
</cite></p>
<p>They are no more pain in the neck than, say, NullPonterExceptions. They simply signify the data you ask has not been loaded from database. What would you expect Hibernate to do. If the data is not there, you can either:</p>
<p>1) make sure you fetch it, before you operate on it<br />
2) leave the session open, so Hibernate will do that for you (say, by means of OpenSessionInViewFilter)</p>
<p>Lastly, I wholeheartedly agree with your last paragraph.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: javaguy</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-284</link>
		<dc:creator>javaguy</dc:creator>
		<pubDate>Tue, 20 Oct 2009 08:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-284</guid>
		<description>ibatis
 - dead simple
 - ibator to gen your persistence domain pojos and daos
 - 1 jar</description>
		<content:encoded><![CDATA[<p>ibatis<br />
 &#8211; dead simple<br />
 &#8211; ibator to gen your persistence domain pojos and daos<br />
 &#8211; 1 jar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: igor</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-283</link>
		<dc:creator>igor</dc:creator>
		<pubDate>Tue, 20 Oct 2009 07:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-283</guid>
		<description>There are always lightweight solutions: http://jodd.org/doc/db/index.html</description>
		<content:encoded><![CDATA[<p>There are always lightweight solutions: <a href="http://jodd.org/doc/db/index.html">http://jodd.org/doc/db/index.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris</title>
		<link>http://blog.schauderhaft.de/2009/10/18/hibernate-problems-alternative/comment-page-1/#comment-282</link>
		<dc:creator>Dimitris</dc:creator>
		<pubDate>Mon, 19 Oct 2009 12:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.schauderhaft.de/?p=294#comment-282</guid>
		<description>&quot;Annotations feel like dirt in your code, and maintaining XML mappings is just painful.&quot;
&quot;The problem with annotations is: they don’t belong in the business domain, where your classes live.&quot;

I had the same concerns, however I found a solution. I am using the JPA API but I still keep using xdoclet to automatically generate xml mappings! The downside is that meta data kept in Hibernate proprietary form.</description>
		<content:encoded><![CDATA[<p>&#8220;Annotations feel like dirt in your code, and maintaining XML mappings is just painful.&#8221;<br />
&#8220;The problem with annotations is: they don’t belong in the business domain, where your classes live.&#8221;</p>
<p>I had the same concerns, however I found a solution. I am using the JPA API but I still keep using xdoclet to automatically generate xml mappings! The downside is that meta data kept in Hibernate proprietary form.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
