<?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/"
	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>Deprecated Consciousness</title>
	<atom:link href="http://deprecatedconsciousness.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://deprecatedconsciousness.wordpress.com</link>
	<description>Yet another technical blog</description>
	<lastBuildDate>Thu, 16 Dec 2010 19:57:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='deprecatedconsciousness.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Deprecated Consciousness</title>
		<link>http://deprecatedconsciousness.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://deprecatedconsciousness.wordpress.com/osd.xml" title="Deprecated Consciousness" />
	<atom:link rel='hub' href='http://deprecatedconsciousness.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Spring Security 3 schema changes</title>
		<link>http://deprecatedconsciousness.wordpress.com/2009/12/01/spring-security-3-schema-changes/</link>
		<comments>http://deprecatedconsciousness.wordpress.com/2009/12/01/spring-security-3-schema-changes/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 18:16:41 +0000</pubDate>
		<dc:creator>electrikmonk</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring-security]]></category>

		<guid isPermaLink="false">http://deprecatedconsciousness.wordpress.com/?p=24</guid>
		<description><![CDATA[I was upgrading my application from Spring 2.5.6 + Spring Security 2.0.x to the latest 3.0 RC releases. After modifying my Maven pom.xml files to accomodate for the new artifact naming conventions, I still couldn&#8217;t get my application context to load due to a SAX exception: I found myself spending almost an hour trying to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deprecatedconsciousness.wordpress.com&amp;blog=10670749&amp;post=24&amp;subd=deprecatedconsciousness&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was upgrading my application from Spring 2.5.6 + Spring Security 2.0.x to the latest 3.0 RC releases. After modifying my Maven pom.xml files to accomodate for the new artifact naming conventions, I still couldn&#8217;t get my application context to load due to a SAX exception:</p>
<p><pre class="brush: java;">
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 37 in XML document from class path resource [security-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'security:authentication-provider'.
</pre></p>
<p>I found myself spending almost an hour trying to figure out what&#8217;s wrong with my configuration file. Was I missing a JAR file? no, everything seems to be in its right place (you WILL want to make sure that you&#8217;re including spring-security-config.jar, though!), Eclipse didn&#8217;t detect anything wrong with the config file. In my despair, I turned to <a href="http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ns-config.html">Security Namespace Configuration</a> chapter of the Spring Security 3 reference manual. There I noticed the following paragraph:</p>
<p><pre class="brush: xml;">
  &lt;authentication-manager&gt;
    &lt;authentication-provider&gt;
      &lt;user-service&gt;
        &lt;user name=&quot;jimi&quot; password=&quot;jimispassword&quot; authorities=&quot;ROLE_USER, ROLE_ADMIN&quot; /&gt;
        &lt;user name=&quot;bob&quot; password=&quot;bobspassword&quot; authorities=&quot;ROLE_USER&quot; /&gt;
      &lt;/user-service&gt;
    &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
</pre></p>
<p>Turning to my own configuration file, I saw this:</p>
<p><pre class="brush: xml;">
&lt;security:authentication-provider user-service-ref=&quot;userService&quot;&gt;
   &lt;security:password-encoder ref=&quot;passwordEncoder&quot;&gt;
      &lt;security:salt-source user-property=&quot;username&quot;/&gt;
   &lt;/security:password-encoder&gt;
&lt;/security:authentication-provider&gt;

&lt;security:authentication-manager alias=&quot;authenticationManager&quot;/&gt;
</pre></p>
<p>Apparently, while in Spring Security 2.x the <em>authentication-provider</em> tag used to be a root-level citizen, now it must live inside the <em>authentication-manager</em> definition.</p>
<p>I hope this will save some other folks some time when migrating to the 3.x Spring stack.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deprecatedconsciousness.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deprecatedconsciousness.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deprecatedconsciousness.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deprecatedconsciousness.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deprecatedconsciousness.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deprecatedconsciousness.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deprecatedconsciousness.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deprecatedconsciousness.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deprecatedconsciousness.wordpress.com&amp;blog=10670749&amp;post=24&amp;subd=deprecatedconsciousness&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deprecatedconsciousness.wordpress.com/2009/12/01/spring-security-3-schema-changes/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<georss:point>32.081000 34.814000</georss:point>
		<geo:lat>32.081000</geo:lat>
		<geo:long>34.814000</geo:long>
		<media:content url="http://0.gravatar.com/avatar/e68285df5c6b2561d0453845b7b2b5ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">electrikmonk</media:title>
		</media:content>
	</item>
		<item>
		<title>Cascade Delete foreign keys using Hibernate hbm2ddl</title>
		<link>http://deprecatedconsciousness.wordpress.com/2009/11/25/cascade-delete-foreign-keys-using-hibernate-hbm2ddl/</link>
		<comments>http://deprecatedconsciousness.wordpress.com/2009/11/25/cascade-delete-foreign-keys-using-hibernate-hbm2ddl/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 13:48:11 +0000</pubDate>
		<dc:creator>electrikmonk</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[Hibernate]]></category>

		<guid isPermaLink="false">http://deprecatedconsciousness.wordpress.com/?p=10</guid>
		<description><![CDATA[It turns out that, for some odd reason, when creating foreign keys for OneToMany / ManyToOne relationships, Hibernate completely ignore the @Cascade annotations or the cascade keyword of the join annotation.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deprecatedconsciousness.wordpress.com&amp;blog=10670749&amp;post=10&amp;subd=deprecatedconsciousness&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Even though I&#8217;ve been working with <a href="http://www.hibernate.org">Hibernate</a> for 3 years now, I&#8217;ve only just run into this issue &#8211; most likely because in past projects we&#8217;ve used POJO generations and now, for the first time in a real life project, I&#8217;m using the Schema Export tool.</p>
<p>It turns out that, for some odd reason, when creating foreign keys for OneToMany / ManyToOne relationships, Hibernate completely ignore the @Cascade annotations or the cascade keyword of the join annotation.</p>
<p>For instance, consider the following model:</p>
<p><pre class="brush: java;">

@Entity
public class Cat {

 @Id
 @GeneratedValue
 @Column
 private Long id;

 @Column
 private String name;

 @OneToMany(mappedBy = &quot;parent&quot;, cascade = {CascadeType.ALL})
 @ForeignKey(name = &quot;FK_KITTEN_PARENT&quot;)
 private List kittens = new ArrayList();

}

@Entity
public class Kitten {

 @Id
 @Column
 @GeneratedValue
 private Long id;

 @ManyToOne(cascade = CascadeType.ALL)
 private Cat parent;

 @Column
 private String name;
}
</pre></p>
<p>The resulting DDL for these two classes will be:</p>
<p><pre class="brush: sql;">
create table Cat (id bigint not null auto_increment, name varchar(255), primary key (id)) ENGINE=InnoDB

create table Kitten (id bigint not null auto_increment, name varchar(255), parent_id bigint, primary key (id)) ENGINE=InnoDB

alter table Kitten add index FK_KITTEN_PARENT (parent_id), add constraint FK_KITTEN_PARENT foreign key (parent_id) references Cat (id)
</pre></p>
<p>This behavior does not seem to be documented anywhere. The Hibernate guys seem to think it&#8217;s natural for people to assume that the CascadeType and @Cascade definitions are not translated into DDL. What Hibernate does, instead of generating DDL, is automatically deleting the children (Kittens, in our case) of a deleted parent, <strong>when you use the <a href="https://www.hibernate.org/hib_docs/v3/api/org/hibernate/Criteria.html">Criteria API</a></strong>. And what if you happen to use HQL? tough.</p>
<p>Fortunately, there IS a solution. It involves using the not-so-well documented annotation (or XML attribute) <a href="http://docs.jboss.org/hibernate/stable/annotations/api/org/hibernate/annotations/OnDelete.html">@OnDelete</a> on the parent (Cat, in our case) side of the association, thus:</p>
<p><pre class="brush: java;">
@Entity
public class Cat {

@Id
@GeneratedValue
@Column
private Long id;

@Column
private String name;

@OneToMany(mappedBy = &quot;parent&quot;, cascade = {CascadeType.ALL})
@ForeignKey(name = &quot;FK_KITTEN_PARENT&quot;)
@OnDelete(action = OnDeleteAction.CASCADE)
private List&lt;Kitten&gt; kittens = new ArrayList&lt;Kitten&gt;();
</pre></p>
<p>This ensures that the foreign key is created with the appropriate <em>on delete cascade</em> clause and allowing you to safely delete your parent entities not worrying about any children that refer to them.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/deprecatedconsciousness.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/deprecatedconsciousness.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/deprecatedconsciousness.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/deprecatedconsciousness.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/deprecatedconsciousness.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/deprecatedconsciousness.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/deprecatedconsciousness.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/deprecatedconsciousness.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=deprecatedconsciousness.wordpress.com&amp;blog=10670749&amp;post=10&amp;subd=deprecatedconsciousness&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://deprecatedconsciousness.wordpress.com/2009/11/25/cascade-delete-foreign-keys-using-hibernate-hbm2ddl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<georss:point>32.081000 34.814000</georss:point>
		<geo:lat>32.081000</geo:lat>
		<geo:long>34.814000</geo:long>
		<media:content url="http://0.gravatar.com/avatar/e68285df5c6b2561d0453845b7b2b5ac?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">electrikmonk</media:title>
		</media:content>
	</item>
	</channel>
</rss>
