<?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"
	>
<channel>
	<title>Comments on: Hibernate Pitfalls part 2</title>
	<atom:link href="http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/</link>
	<description>Brian Pontarelli</description>
	<pubDate>Wed, 07 Jan 2009 01:30:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Pete</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-35197</link>
		<dc:creator>Pete</dc:creator>
		<pubDate>Thu, 06 Nov 2008 11:16:27 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-35197</guid>
		<description>Brian Pontarelli's post a year and a half ago just helped massively. We had Hibernate automatically saving objects to the database without being asked - calling session.clear() was the solution. Brian's post was clearer than all the hibernate documentation!</description>
		<content:encoded><![CDATA[<p>Brian Pontarelli&#8217;s post a year and a half ago just helped massively. We had Hibernate automatically saving objects to the database without being asked - calling session.clear() was the solution. Brian&#8217;s post was clearer than all the hibernate documentation!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-32792</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Fri, 26 Sep 2008 16:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-32792</guid>
		<description>We ran into this same issue recently.  We were surprised to have objects persisted when we never called save on them.  Pretty lame "feature" if you ask me.  Calling evict or session.clear is not a good solution for this issue.</description>
		<content:encoded><![CDATA[<p>We ran into this same issue recently.  We were surprised to have objects persisted when we never called save on them.  Pretty lame &#8220;feature&#8221; if you ask me.  Calling evict or session.clear is not a good solution for this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Object Relational Mapping Sucks - Hibernate Critical &#171; Akantos</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-31532</link>
		<dc:creator>Object Relational Mapping Sucks - Hibernate Critical &#171; Akantos</dc:creator>
		<pubDate>Thu, 04 Sep 2008 22:26:47 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-31532</guid>
		<description>[...] Object Relational Mapping Sucks must be considered. Also Brian Pontarali article series&#8217; Hibernate Pitfalls  should be reviewed and google would be [...]</description>
		<content:encoded><![CDATA[<p>[...] Object Relational Mapping Sucks must be considered. Also Brian Pontarali article series&#8217; Hibernate Pitfalls  should be reviewed and google would be [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andre Piwoni</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-21395</link>
		<dc:creator>Andre Piwoni</dc:creator>
		<pubDate>Wed, 25 Jun 2008 17:39:08 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-21395</guid>
		<description>I don't like implicit flush either. As far as Christian's solution goes, which does not work with JPA, I don't think that using evict() and clear() is really too helpful in any other abstract data layer implemented using Hibernate and JTA. 

I found that forcing FlushMode to MANUAL, since JTASessionContext defaults to flush before transaction completion, and calling flush() on update operations and finally commit() or rollback() is more flexible. Christian may argue that his approach is more efficient, and while I agree, I argue that it is impractical.

Andre</description>
		<content:encoded><![CDATA[<p>I don&#8217;t like implicit flush either. As far as Christian&#8217;s solution goes, which does not work with JPA, I don&#8217;t think that using evict() and clear() is really too helpful in any other abstract data layer implemented using Hibernate and JTA. </p>
<p>I found that forcing FlushMode to MANUAL, since JTASessionContext defaults to flush before transaction completion, and calling flush() on update operations and finally commit() or rollback() is more flexible. Christian may argue that his approach is more efficient, and while I agree, I argue that it is impractical.</p>
<p>Andre</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Bygrave</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3496</link>
		<dc:creator>Rob Bygrave</dc:creator>
		<pubDate>Thu, 12 Apr 2007 20:56:52 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3496</guid>
		<description>I can see your point Brian - but again I'm biased as I wrote Ebean which requires an explicit save() and delete() unlike JPA (and is session less). 

I'd be interested to hear your thoughts on 'session less' ORMs such as Ebean.</description>
		<content:encoded><![CDATA[<p>I can see your point Brian - but again I&#8217;m biased as I wrote Ebean which requires an explicit save() and delete() unlike JPA (and is session less). </p>
<p>I&#8217;d be interested to hear your thoughts on &#8217;session less&#8217; ORMs such as Ebean.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3421</link>
		<dc:creator>Max</dc:creator>
		<pubDate>Fri, 06 Apr 2007 08:55:02 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3421</guid>
		<description>Going to be fun what the next thing is you are complaining about ;) 

It seems you just don't like automatic (or help to do) *state* management. Again StatelessSession would give you full control; but you have declined that previously because it did too little.

As Christian points out there are ways in Hibernate to control this very explicitly (e.g. .setReadOnly).
FYI independent on your "series" we have been talking for a while about adding a session.setReadOnly(x) flag that you could use to get your "be-more-explicit-and-requires-more-user-code" approach.)

Your "series" seem to forget the downsides of your alternate approaches. Most users I have talked to actually gets very happy when they realize they don't have to keep track on if a thirdparty library or code changed their objects; if they had to do that they would have to write alot more code and most likely that code would be much more inefficient (both in runtime and developer performance).

And yes, I've met people too that were surprised over some behavior but in general when they were explained why it was and what you would miss if it weren't there peoples opinion turns. 

And if that does not help them Hibernate still in many cases allow you to configure or use it the way you like - it is just not the way it works by default nor the way we document the most (since it would give alot of other issues)</description>
		<content:encoded><![CDATA[<p>Going to be fun what the next thing is you are complaining about ;) </p>
<p>It seems you just don&#8217;t like automatic (or help to do) *state* management. Again StatelessSession would give you full control; but you have declined that previously because it did too little.</p>
<p>As Christian points out there are ways in Hibernate to control this very explicitly (e.g. .setReadOnly).<br />
FYI independent on your &#8220;series&#8221; we have been talking for a while about adding a session.setReadOnly(x) flag that you could use to get your &#8220;be-more-explicit-and-requires-more-user-code&#8221; approach.)</p>
<p>Your &#8220;series&#8221; seem to forget the downsides of your alternate approaches. Most users I have talked to actually gets very happy when they realize they don&#8217;t have to keep track on if a thirdparty library or code changed their objects; if they had to do that they would have to write alot more code and most likely that code would be much more inefficient (both in runtime and developer performance).</p>
<p>And yes, I&#8217;ve met people too that were surprised over some behavior but in general when they were explained why it was and what you would miss if it weren&#8217;t there peoples opinion turns. </p>
<p>And if that does not help them Hibernate still in many cases allow you to configure or use it the way you like - it is just not the way it works by default nor the way we document the most (since it would give alot of other issues)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Pontarelli</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3417</link>
		<dc:creator>Brian Pontarelli</dc:creator>
		<pubDate>Fri, 06 Apr 2007 02:21:32 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3417</guid>
		<description>&lt;blockquote&gt;
No, itâ€™s just you. Stop using â€œmany othersâ€ as an excuse for your poor technical arguments. Apparently you donâ€™t know what session.evict() and session.clear() are doing. Using these together with session.update() you can get your desired â€œI want to tell Hibernate to update explicitlyâ€ behavior. You can also disable automatic dirty checking and updating by disabling the snapshots in Hibernate with session.setReadOnly(o, true) or for all queried objects with query.setReadOnly(true). Your conclusions about refresh() are completely wrong, it is not used for what you think it is used. This stuff just doesnâ€™t work as you think it should work.
&lt;/blockquote&gt;

No, there has already been one person who commented that they left Hibernate behind due to maintainability. Just because the opponents aren't as vocal as I am doesn't mean they aren't out there. I know and have had long discussions with many folks who are not Hibernate fans.

I feel that you really missed the point of the post if you think that evict and clear will fix this issue. Remember that this is JPA and not Hibernate APIs and regardless I didn't miss the point about refresh, it does exactly what is stated. Let's look that them quick:

refresh (javadoc) - "Refresh the state of the instance from the database, overwriting changes made to the entity, if any."

refresh (me) - "which essentially rolls back a single entity."

clear (javadoc) - Clear the persistence context, causing all managed entities to become detached.

clear (me) - didn't even mention it, but this would essentially make all the work I've done thus far worthless because everything would be detached and no longer lazy loadable or really usable as persistent entities.

Although I didn't mention clear, my use of refresh was accurate.

Lastly, dirty checking would work, but again this is JPA. Still though, I might pass an Object to a library and not realize I need to set it to read only. What I'm saying is that the method of least surprise is to programmatically update objects via the persist or an update method and NOT via dirty checking. It is usually very difficult to track down if and where objects changed in large code bases (such as a few hundred codebases of a few hundred classes a piece).

To sum up, I know that many folks love Hibernate and feel that it solves all the worlds problems, but I'm being quite pragmatic and thinking about large and small code bases with large and small teams and the possibility of having junior or mid level developers working in the code.</description>
		<content:encoded><![CDATA[<blockquote><p>
No, itâ€™s just you. Stop using â€œmany othersâ€ as an excuse for your poor technical arguments. Apparently you donâ€™t know what session.evict() and session.clear() are doing. Using these together with session.update() you can get your desired â€œI want to tell Hibernate to update explicitlyâ€ behavior. You can also disable automatic dirty checking and updating by disabling the snapshots in Hibernate with session.setReadOnly(o, true) or for all queried objects with query.setReadOnly(true). Your conclusions about refresh() are completely wrong, it is not used for what you think it is used. This stuff just doesnâ€™t work as you think it should work.
</p></blockquote>
<p>No, there has already been one person who commented that they left Hibernate behind due to maintainability. Just because the opponents aren&#8217;t as vocal as I am doesn&#8217;t mean they aren&#8217;t out there. I know and have had long discussions with many folks who are not Hibernate fans.</p>
<p>I feel that you really missed the point of the post if you think that evict and clear will fix this issue. Remember that this is JPA and not Hibernate APIs and regardless I didn&#8217;t miss the point about refresh, it does exactly what is stated. Let&#8217;s look that them quick:</p>
<p>refresh (javadoc) - &#8220;Refresh the state of the instance from the database, overwriting changes made to the entity, if any.&#8221;</p>
<p>refresh (me) - &#8220;which essentially rolls back a single entity.&#8221;</p>
<p>clear (javadoc) - Clear the persistence context, causing all managed entities to become detached.</p>
<p>clear (me) - didn&#8217;t even mention it, but this would essentially make all the work I&#8217;ve done thus far worthless because everything would be detached and no longer lazy loadable or really usable as persistent entities.</p>
<p>Although I didn&#8217;t mention clear, my use of refresh was accurate.</p>
<p>Lastly, dirty checking would work, but again this is JPA. Still though, I might pass an Object to a library and not realize I need to set it to read only. What I&#8217;m saying is that the method of least surprise is to programmatically update objects via the persist or an update method and NOT via dirty checking. It is usually very difficult to track down if and where objects changed in large code bases (such as a few hundred codebases of a few hundred classes a piece).</p>
<p>To sum up, I know that many folks love Hibernate and feel that it solves all the worlds problems, but I&#8217;m being quite pragmatic and thinking about large and small code bases with large and small teams and the possibility of having junior or mid level developers working in the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3403</link>
		<dc:creator>Christian</dc:creator>
		<pubDate>Thu, 05 Apr 2007 05:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-3403</guid>
		<description>" I and many others have felt for a long time with Hibernate."

No, it's just you. Stop using "many others" as an excuse for your poor technical arguments. Apparently you don't know what session.evict() and session.clear() are doing. Using these together with session.update() you can get your desired "I want to tell Hibernate to update explicitly" behavior. You can also disable automatic dirty checking and updating by disabling the snapshots in Hibernate with session.setReadOnly(o, true) or for all queried objects with query.setReadOnly(true). Your conclusions about refresh() are completely wrong, it is not used for what you think it is used. This stuff just doesn't work as you think it should work.

Can you please stop this now and invest some more time in learning the basics?</description>
		<content:encoded><![CDATA[<p>&#8221; I and many others have felt for a long time with Hibernate.&#8221;</p>
<p>No, it&#8217;s just you. Stop using &#8220;many others&#8221; as an excuse for your poor technical arguments. Apparently you don&#8217;t know what session.evict() and session.clear() are doing. Using these together with session.update() you can get your desired &#8220;I want to tell Hibernate to update explicitly&#8221; behavior. You can also disable automatic dirty checking and updating by disabling the snapshots in Hibernate with session.setReadOnly(o, true) or for all queried objects with query.setReadOnly(true). Your conclusions about refresh() are completely wrong, it is not used for what you think it is used. This stuff just doesn&#8217;t work as you think it should work.</p>
<p>Can you please stop this now and invest some more time in learning the basics?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
