<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pencils Down &#187; Delete</title>
	<atom:link href="http://www.dantoomeysoftware.com/pencils-down/tag/delete/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dantoomeysoftware.com/pencils-down</link>
	<description>This weblog is about my experiences in software development</description>
	<lastBuildDate>Fri, 27 Jan 2012 13:43:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Can we Delete Cascading Delete?</title>
		<link>http://www.dantoomeysoftware.com/pencils-down/2008/09/18/can-we-delete-cascading-delete/</link>
		<comments>http://www.dantoomeysoftware.com/pencils-down/2008/09/18/can-we-delete-cascading-delete/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 15:07:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http://www.dantoomeysoftware.com/pencils-down/2008/09/18/can-we-delete-cascading-delete/</guid>
		<description><![CDATA[I think we have a fairly standard database that looks like a parts BOMB.  Someone had the neato idea to use cascading delete in the project.  Hibernate&#8217;s cascading delete will follow any required foreign key and delete the children it finds there in a cyclical manner.  Good idea, huh?
No.  This means parent entity Parent with [...]]]></description>
			<content:encoded><![CDATA[<p>I think we have a fairly standard database that looks like a parts BOMB.  Someone had the neato idea to use cascading delete in the project.  Hibernate&#8217;s cascading delete will follow any required foreign key and delete the children it finds there in a cyclical manner.  Good idea, huh?</p>
<p>No.  This means parent entity Parent with a primary key of ParentPrimaryKey MUST cascade it&#8217;s primary key to all children.  So, entity Child has a primary key of ChildPrimaryKey PLUS ParentPrimaryKey.  This continues all the way down your entity tree.  This example assumes simple row id&#8217;s for primary key.  If there was some other overriding attribute which makes every primary key a composite, like SystemThatThisEntityLivesOn, then every level has one of those plus all the parent&#8217;s.</p>
<p>Then we realize, we can&#8217;t actually delete some of the lower level entities because they are a lot of work to create.  So, we configure Hibernate to stop at those entities.</p>
<p>Now if we step back and look at the entity diagram for our database it is not uncommon for an entity at a lower level to have close to 20 component parts of a primary key that have cascaded down.</p>
<p>But, we only delete via cascade a very small subset of the entity tree.</p>
<p>Now, throw into the mix some developers who don&#8217;t understand the above features of a relational database or Hibernate in general and we now can&#8217;t use the LowLevelEntityId composite object that Hibernate generates as that is &#8216;unclean&#8217;.  We are to flatten all of these id&#8217;s wherever used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dantoomeysoftware.com/pencils-down/2008/09/18/can-we-delete-cascading-delete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

