<?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>Sat, 13 Mar 2010 19:11:37 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Andre Piwoni</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-94140</link>
		<dc:creator>Andre Piwoni</dc:creator>
		<pubDate>Fri, 23 Oct 2009 00:34:19 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-94140</guid>
		<description>In response to jens statement that
"OK setting FLUSHMODE to never is easy but you first have to figure this out and you then introduce some strange “Persistance Layer” dependant Logic into your code"

What do you mean by strange persistance layer? You access data via simple persistence layer (think of something like Generic DAO) which encapsulates this behavior? How complex this is:

    public void delete( T argObject )
    {
        Session session = getSession();
        session.delete( argObject );
        session.flush();
    }

When you are done code upstream does commit or rollback.
Is there anything that you see here that requires upstream code to have some persistence layer dependent logic?</description>
		<content:encoded><![CDATA[<p>In response to jens statement that<br />
&#8220;OK setting FLUSHMODE to never is easy but you first have to figure this out and you then introduce some strange “Persistance Layer” dependant Logic into your code&#8221;</p>
<p>What do you mean by strange persistance layer? You access data via simple persistence layer (think of something like Generic DAO) which encapsulates this behavior? How complex this is:</p>
<p>    public void delete( T argObject )<br />
    {<br />
        Session session = getSession();<br />
        session.delete( argObject );<br />
        session.flush();<br />
    }</p>
<p>When you are done code upstream does commit or rollback.<br />
Is there anything that you see here that requires upstream code to have some persistence layer dependent logic?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: inca</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-93570</link>
		<dc:creator>inca</dc:creator>
		<pubDate>Sat, 17 Oct 2009 11:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-93570</guid>
		<description>"Automatic dirty checking" is a design pattern, that has it's own synopsis and therefore fits only certain circumstances. Apparently, it does not fit the Open Session In View pattern: collecting values into an attached entity object, then validating this object and then deciding, whether persist it or not. While the session is alive all the way, you'll get updates before you will be able to validate (even if you will eventually decide not to do so).
Now a word about workarounds. The worst thing the developer may do is to introduce his own workarounds to avoid some undesirable features.</description>
		<content:encoded><![CDATA[<p>&#8220;Automatic dirty checking&#8221; is a design pattern, that has it&#8217;s own synopsis and therefore fits only certain circumstances. Apparently, it does not fit the Open Session In View pattern: collecting values into an attached entity object, then validating this object and then deciding, whether persist it or not. While the session is alive all the way, you&#8217;ll get updates before you will be able to validate (even if you will eventually decide not to do so).<br />
Now a word about workarounds. The worst thing the developer may do is to introduce his own workarounds to avoid some undesirable features.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jens</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-89910</link>
		<dc:creator>jens</dc:creator>
		<pubDate>Sun, 13 Sep 2009 16:03:58 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-89910</guid>
		<description>Hello,

I also think Brians Post is very helpfull. Thank you very much Brian, please keep up the good work. 

Hibernate tries to "solve" some of the problems of the SQL/Relationalworld but on the otherhand therefore imposes problems on another level.  Hibernate tries sometimes to be too smart. In regard to the article the FLUSHMODE = AUTO  I consider not necessarly as a Feature. I had serious Problems for example if you do a series of validations and one fails then the object is in an indeterministic state. But Hibernate happly will update the database. You than have to introduce logic to prevent this. OK setting FLUSHMODE to never is easy but you first have to figure this out and you then introduce some strange "Persistance Layer" dependant Logic into your code. So I think the post Hibernate Pitfalls 1 an 2 are very helpfull!</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I also think Brians Post is very helpfull. Thank you very much Brian, please keep up the good work. </p>
<p>Hibernate tries to &#8220;solve&#8221; some of the problems of the SQL/Relationalworld but on the otherhand therefore imposes problems on another level.  Hibernate tries sometimes to be too smart. In regard to the article the FLUSHMODE = AUTO  I consider not necessarly as a Feature. I had serious Problems for example if you do a series of validations and one fails then the object is in an indeterministic state. But Hibernate happly will update the database. You than have to introduce logic to prevent this. OK setting FLUSHMODE to never is easy but you first have to figure this out and you then introduce some strange &#8220;Persistance Layer&#8221; dependant Logic into your code. So I think the post Hibernate Pitfalls 1 an 2 are very helpfull!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kurt Harriger</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-86523</link>
		<dc:creator>Kurt Harriger</dc:creator>
		<pubDate>Sat, 22 Aug 2009 04:46:24 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-86523</guid>
		<description>I agree... just blogged about this myself.

http://kurtharriger.wordpress.com/2009/08/21/how-nhibernates-dirty-checking-violates-encapsulation-boundries/</description>
		<content:encoded><![CDATA[<p>I agree&#8230; just blogged about this myself.</p>
<p><a href="http://kurtharriger.wordpress.com/2009/08/21/how-nhibernates-dirty-checking-violates-encapsulation-boundries/" rel="nofollow">http://kurtharriger.wordpress.com/2009/08/21/how-nhibernates-dirty-checking-violates-encapsulation-boundries/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-85674</link>
		<dc:creator>Carlos</dc:creator>
		<pubDate>Thu, 13 Aug 2009 20:11:58 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-85674</guid>
		<description>Again this post is simple ignorance of the principles behind the development of Hibernate.

I agree with Andre Piwoni, all of these pitfalls can be fixed by setting AutoFlushMode = Never</description>
		<content:encoded><![CDATA[<p>Again this post is simple ignorance of the principles behind the development of Hibernate.</p>
<p>I agree with Andre Piwoni, all of these pitfalls can be fixed by setting AutoFlushMode = Never</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: inca</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-84350</link>
		<dc:creator>inca</dc:creator>
		<pubDate>Sun, 12 Jul 2009 13:09:20 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-84350</guid>
		<description>No, Mark, it is not. I personally will never fall back to plain JDBC even in the most trivial cases. And still these implicit updates are lame stuff for sure. I would at least consider it being optional feature (disabled by default). 
As for the Christian's comment -- the worst workaround for such an offense. Are POJOs recovered from persistence context supposed to participate in some business logic? And what if, depending on that logic, you eventually decide to persist them? If you only have a handfull of queries, then it is probably OK (very ugly though and, yepp, I didn' manage to find an equivalent in Criteria API, which is essentially the 'O' of ORM), but as soon as you deal with tons of queries within a transaction you just have to call readOnly on a unit-of-work, rendering it unable to do further persistence stuff.
Actually I have never saw a beautiful solution for that 'feature' -- just ugly workarounds.</description>
		<content:encoded><![CDATA[<p>No, Mark, it is not. I personally will never fall back to plain JDBC even in the most trivial cases. And still these implicit updates are lame stuff for sure. I would at least consider it being optional feature (disabled by default).<br />
As for the Christian&#8217;s comment &#8212; the worst workaround for such an offense. Are POJOs recovered from persistence context supposed to participate in some business logic? And what if, depending on that logic, you eventually decide to persist them? If you only have a handfull of queries, then it is probably OK (very ugly though and, yepp, I didn&#8217; manage to find an equivalent in Criteria API, which is essentially the &#8216;O&#8217; of ORM), but as soon as you deal with tons of queries within a transaction you just have to call readOnly on a unit-of-work, rendering it unable to do further persistence stuff.<br />
Actually I have never saw a beautiful solution for that &#8216;feature&#8217; &#8212; just ugly workarounds.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-83080</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 25 Jun 2009 16:07:37 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-83080</guid>
		<description>I totally agree with Brian and StickyBandit. We are using Hibernate for our project and writing HQLs most times. I really don't see any point using Hibernate. In most cases, I believe, the pure JDBC is still the best way to go.</description>
		<content:encoded><![CDATA[<p>I totally agree with Brian and StickyBandit. We are using Hibernate for our project and writing HQLs most times. I really don&#8217;t see any point using Hibernate. In most cases, I believe, the pure JDBC is still the best way to go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: StickyBandit</title>
		<link>http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-82204</link>
		<dc:creator>StickyBandit</dc:creator>
		<pubDate>Fri, 12 Jun 2009 20:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://brian.pontarelli.com/2007/04/03/hibernate-pitfalls-part-2/#comment-82204</guid>
		<description>Remember the Atari game 'Pitfall'?  That's what it's like using hibernate.  You have to jump over one pit and then onto the next pit, jump, jump, jump.  I am doing all this so that I don't have write some SQL?  Hardly seems worth it to me.  Especially when I still end up writing SQL wrapped in HSQL for all the complex stuff anyway.  Huh?  Am I the only one who thinks this is the worst idea that ever got popular?</description>
		<content:encoded><![CDATA[<p>Remember the Atari game &#8216;Pitfall&#8217;?  That&#8217;s what it&#8217;s like using hibernate.  You have to jump over one pit and then onto the next pit, jump, jump, jump.  I am doing all this so that I don&#8217;t have write some SQL?  Hardly seems worth it to me.  Especially when I still end up writing SQL wrapped in HSQL for all the complex stuff anyway.  Huh?  Am I the only one who thinks this is the worst idea that ever got popular?</p>
]]></content:encoded>
	</item>
	<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>
</channel>
</rss>
