<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Differences in behaviour between Hibernate delete queries and the old way</title>
	<atom:link href="http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/feed/" rel="self" type="application/rss+xml" />
	<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/</link>
	<description>Robert&#039;s Rambling Ruminations Regarding Reality...</description>
	<lastBuildDate>Thu, 12 Apr 2012 16:31:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Ravi</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-203</link>
		<dc:creator><![CDATA[Ravi]]></dc:creator>
		<pubDate>Tue, 31 Jan 2006 16:40:41 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-203</guid>
		<description><![CDATA[the main thing about versioned data is that there&#039;s a common requirement for following some sort of expiration protocol. i use hibernate because it makes it easy for me to map an object tree. now when it comes to deleting this tree (assuming for a moment database cascading doesn&#039;t exist) who knows best what the mapping pattern is? yup, hibernate - as knows most about the exact mappings/relationships.

loading this entire archived tree into memory is a waste of time and resources if i follow the H2 style deletion. H3 deletion is a good step forward but practically of no use in this regard. as of this writing i still don&#039;t see an efficient solution to large tree deletions (bulk or not).
]]></description>
		<content:encoded><![CDATA[<p>the main thing about versioned data is that there&#8217;s a common requirement for following some sort of expiration protocol. i use hibernate because it makes it easy for me to map an object tree. now when it comes to deleting this tree (assuming for a moment database cascading doesn&#8217;t exist) who knows best what the mapping pattern is? yup, hibernate &#8211; as knows most about the exact mappings/relationships.</p>
<p>loading this entire archived tree into memory is a waste of time and resources if i follow the H2 style deletion. H3 deletion is a good step forward but practically of no use in this regard. as of this writing i still don&#8217;t see an efficient solution to large tree deletions (bulk or not).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-202</link>
		<dc:creator><![CDATA[Michael]]></dc:creator>
		<pubDate>Thu, 21 Apr 2005 13:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-202</guid>
		<description><![CDATA[I agree with Robert. I would be naive and &quot;hope&quot; that uber-smart Hibernate would know what to do if I am using HQL for bulk delete.

Bulk delete with cascading is nice. For example, I need to remove all record of a clients project details. Of course, in practice they tend to be &quot;logical&quot; deletes anyway, so perhaps this is a storm in a teacup.

However I understand that &quot;true&quot; bulk deletes would be pretty hard to do without just effectively doing fetch into memory, call delete, cascade underneath.

But now I know to explicitly do it - great !
]]></description>
		<content:encoded><![CDATA[<p>I agree with Robert. I would be naive and &#8220;hope&#8221; that uber-smart Hibernate would know what to do if I am using HQL for bulk delete.</p>
<p>Bulk delete with cascading is nice. For example, I need to remove all record of a clients project details. Of course, in practice they tend to be &#8220;logical&#8221; deletes anyway, so perhaps this is a storm in a teacup.</p>
<p>However I understand that &#8220;true&#8221; bulk deletes would be pretty hard to do without just effectively doing fetch into memory, call delete, cascade underneath.</p>
<p>But now I know to explicitly do it &#8211; great !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-201</link>
		<dc:creator><![CDATA[Robert]]></dc:creator>
		<pubDate>Thu, 21 Apr 2005 07:27:25 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-201</guid>
		<description><![CDATA[Gavin, the only real problem I have with it is that it&#039;s not very clear in the documentation that is the case. :) The Hibernate doco says &quot;see the EJB 3 spec&quot;. The EJB 3 spec doesn&#039;t say anything, one way or the other, about the cascade behaviour.

Perhaps no-one who understands the difficulties expects cascades to be respected; but naively I did,  and I&#039;m sure other people naively have as well. Perhaps the use case I had for it (a test utility to reset the database to a clean state) is unusual for production code. :)

In any case, once I became aware of the differences, the differences weren&#039;t a problem; it was the lack of knowledge that hurt. This (and the other) blog entries are largely to help me never forget.
]]></description>
		<content:encoded><![CDATA[<p>Gavin, the only real problem I have with it is that it&#8217;s not very clear in the documentation that is the case. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  The Hibernate doco says &#8220;see the EJB 3 spec&#8221;. The EJB 3 spec doesn&#8217;t say anything, one way or the other, about the cascade behaviour.</p>
<p>Perhaps no-one who understands the difficulties expects cascades to be respected; but naively I did,  and I&#8217;m sure other people naively have as well. Perhaps the use case I had for it (a test utility to reset the database to a clean state) is unusual for production code. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In any case, once I became aware of the differences, the differences weren&#8217;t a problem; it was the lack of knowledge that hurt. This (and the other) blog entries are largely to help me never forget.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gavin</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-200</link>
		<dc:creator><![CDATA[Gavin]]></dc:creator>
		<pubDate>Thu, 21 Apr 2005 01:11:39 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-200</guid>
		<description><![CDATA[There are two different kinds of thing here:

(1) Fetch a bunch of objects into memory, delete them all, respecting cascades and other lifecycle. You can still do this in HB3, just run a query and iterate over the results, calling delete(). There is no need for the redundant deprecated method.

(2) True bulk delete, which no-one truly expects to respect cascades. (Yes, perhaps it would be *possible* to implement this efficiently in *some cases*, but no-one has ever implemented such a thing before and it looks *very* difficult.) Actually, IMO, bulk delete is not really that useful; it is the bulk *update* that is the most useful piece here.
]]></description>
		<content:encoded><![CDATA[<p>There are two different kinds of thing here:</p>
<p>(1) Fetch a bunch of objects into memory, delete them all, respecting cascades and other lifecycle. You can still do this in HB3, just run a query and iterate over the results, calling delete(). There is no need for the redundant deprecated method.</p>
<p>(2) True bulk delete, which no-one truly expects to respect cascades. (Yes, perhaps it would be *possible* to implement this efficiently in *some cases*, but no-one has ever implemented such a thing before and it looks *very* difficult.) Actually, IMO, bulk delete is not really that useful; it is the bulk *update* that is the most useful piece here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Watkins</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-199</link>
		<dc:creator><![CDATA[Robert Watkins]]></dc:creator>
		<pubDate>Wed, 20 Apr 2005 14:14:21 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-199</guid>
		<description><![CDATA[The EJB 3 spec _has_ cascade deletes. Argubly, the way Hibernate works is compliant (certainly Gavin thinks so, and he helped write the spec).

The way Hibernate 3 works is that deletes cascade when they are called on individual entities (via the Session.delete(Object) method). This, of course, is what Hibernate 2 did under the covers. It&#039;s only when you use the bulk DELETE query that you don&#039;t get the cascade behavior.

The EJB 3 Persistence spec, in its current form (2nd public draft) has exactly 0 words on the interaction of bulk delete or update queries with the EJB lifecycle. According to comments from Hibernate developers, the EJB lifecycle documented in Section 2.3 (where the cascade rules are defined) refers only to in-memory instances that you call remove() on explicitly.

Section 3.11 of the EJB spec defines the bulk UPDATE and DELETE queries. Section 2.3 defines EJB lifecycles - Hibernate objects conform to a similar (but not identical) lifecycle.

]]></description>
		<content:encoded><![CDATA[<p>The EJB 3 spec _has_ cascade deletes. Argubly, the way Hibernate works is compliant (certainly Gavin thinks so, and he helped write the spec).</p>
<p>The way Hibernate 3 works is that deletes cascade when they are called on individual entities (via the Session.delete(Object) method). This, of course, is what Hibernate 2 did under the covers. It&#8217;s only when you use the bulk DELETE query that you don&#8217;t get the cascade behavior.</p>
<p>The EJB 3 Persistence spec, in its current form (2nd public draft) has exactly 0 words on the interaction of bulk delete or update queries with the EJB lifecycle. According to comments from Hibernate developers, the EJB lifecycle documented in Section 2.3 (where the cascade rules are defined) refers only to in-memory instances that you call remove() on explicitly.</p>
<p>Section 3.11 of the EJB spec defines the bulk UPDATE and DELETE queries. Section 2.3 defines EJB lifecycles &#8211; Hibernate objects conform to a similar (but not identical) lifecycle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-198</link>
		<dc:creator><![CDATA[Michael]]></dc:creator>
		<pubDate>Wed, 20 Apr 2005 13:01:43 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-198</guid>
		<description><![CDATA[(I am of course implying that the classic hibernate Session.delete(HQL) was not explicit - maybe it is and I am a bit dim).
]]></description>
		<content:encoded><![CDATA[<p>(I am of course implying that the classic hibernate Session.delete(HQL) was not explicit &#8211; maybe it is and I am a bit dim).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://twasink.net/2005/04/20/differences-in-behaviour-between-hibernate-delete-queries-and-the-old-way/#comment-197</link>
		<dc:creator><![CDATA[Michael]]></dc:creator>
		<pubDate>Wed, 20 Apr 2005 12:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://twasink.net/wp/?p=136#comment-197</guid>
		<description><![CDATA[I am surprised that hibernate or JSR 220 didn&#039;t include an explicit &quot;cascade delete&quot; option that behaved like the classic hibernate delete.

There is nothing inherently bad about the hibernate cascade delete other then the n+1 (but if the method was named suitably, then people would understand what they are getting into when the call the method).

Cascading deletes is one of the scary things in RDBMSes (at least it is for this person, who still wakes up screaming at night... jooohnnnnyyyy).

I know the EJB 3 spec isn&#039;t finished yet, but it would be a bit sad if they left cascade deletes out (the logic would be &quot;well RDBMSes do that best in one call&quot; -but this would mean essentially keeping your relationship logic in the database as well as the hibernate/ejb3 mappings).

Will be an interesting one to watch.
]]></description>
		<content:encoded><![CDATA[<p>I am surprised that hibernate or JSR 220 didn&#8217;t include an explicit &#8220;cascade delete&#8221; option that behaved like the classic hibernate delete.</p>
<p>There is nothing inherently bad about the hibernate cascade delete other then the n+1 (but if the method was named suitably, then people would understand what they are getting into when the call the method).</p>
<p>Cascading deletes is one of the scary things in RDBMSes (at least it is for this person, who still wakes up screaming at night&#8230; jooohnnnnyyyy).</p>
<p>I know the EJB 3 spec isn&#8217;t finished yet, but it would be a bit sad if they left cascade deletes out (the logic would be &#8220;well RDBMSes do that best in one call&#8221; -but this would mean essentially keeping your relationship logic in the database as well as the hibernate/ejb3 mappings).</p>
<p>Will be an interesting one to watch.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

