<?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>my2cents &#187; Software Development</title>
	<atom:link href="http://www.frightanic.com/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frightanic.com</link>
	<description>&#34;The Earth was made round so that we would not see too far down the road&#34; - Karen Blixen</description>
	<lastBuildDate>Wed, 01 Feb 2012 08:20:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>UnknownHostException with &#8216;%&#8217; in IPv6 address</title>
		<link>http://www.frightanic.com/2011/12/23/unknownhostexception-with-in-ipv6-address/</link>
		<comments>http://www.frightanic.com/2011/12/23/unknownhostexception-with-in-ipv6-address/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 08:46:56 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[dnsjava]]></category>
		<category><![CDATA[jee]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=808</guid>
		<description><![CDATA[Recently I tried to use dnsjava to resolve whatever address request.getRemoteAddr() would return. This worked very well in most cases. However, in some cases I would see something like: java.net.UnknownHostException: Invalid address: fe80::1d9:b65a:ed86:7940%11 Not being much of a networking expert I was puzzled about the &#8216;%11&#8242;. Once again superuser.com came to rescue:  http://superuser.com/questions/99746/why-is-there-a-in-the-ipv6-address.]]></description>
			<content:encoded><![CDATA[<p>Recently I tried to use <a href="http://www.dnsjava.org/" target="_blank">dnsjava</a> to resolve whatever address request.getRemoteAddr() would return. This worked very well in most cases. However, in some cases I would see something like:</p>
<pre class="brush:java">java.net.UnknownHostException: Invalid address: fe80::1d9:b65a:ed86:7940%11</pre>
<p>Not being much of a networking expert I was puzzled about the &#8216;%11&#8242;. Once again superuser.com came to rescue:  <a href="http://superuser.com/questions/99746/why-is-there-a-in-the-ipv6-address" target="_blank">http://superuser.com/questions/99746/why-is-there-a-in-the-ipv6-address</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/12/23/unknownhostexception-with-in-ipv6-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corporate culture: Oracle vs. Sun</title>
		<link>http://www.frightanic.com/2011/11/19/corporate-culture-oracle-vs-sun/</link>
		<comments>http://www.frightanic.com/2011/11/19/corporate-culture-oracle-vs-sun/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 19:45:32 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Devoxx]]></category>
		<category><![CDATA[Devoxx 2011]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=805</guid>
		<description><![CDATA[At the technical panel discucssion on Friday morning at Devoxx there was the interesting question &#8220;Does Oracle&#8217;s corporate culture stand in the way of success for Java?&#8221;. Even more interesting was the answer from either Brian Goetz or Mark Reinold (don&#8217;t remember), both big wings at Oracle&#8230; &#8220;I think Java became a success despite Sun&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>At the technical panel discucssion on Friday morning at Devoxx there was the interesting question &#8220;Does Oracle&#8217;s corporate culture stand in the way of success for Java?&#8221;. Even more interesting was the answer from either Brian Goetz or Mark Reinold (don&#8217;t remember), both big wings at Oracle&#8230;</p>
<p>&#8220;I think Java became a success <em>despite</em> Sun&#8217;s corporate culture. Priorities at Sun changed quite rapidly from time to time. At Oracle it takes longer to make a plan but then with stick with it&#8221; (something along the lines of that)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/11/19/corporate-culture-oracle-vs-sun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle is in deep trouble</title>
		<link>http://www.frightanic.com/2011/11/17/oracle-is-in-deep-trouble/</link>
		<comments>http://www.frightanic.com/2011/11/17/oracle-is-in-deep-trouble/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 19:25:16 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Devoxx]]></category>
		<category><![CDATA[Devoxx 2011]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=788</guid>
		<description><![CDATA[The two keynotes at Devoxx 2011 yesterday by Henrik Ståhl and Cameron Purdy from Oracle and today by Google&#8217;s Tim Bray couldn&#8217;t have been more different. If that is all Oracle&#8217;s got to bring to the table then I fear they&#8217;re in big trouble&#8230; While Henrik Ståhl showed at least some passion and inspiration (neatly [...]]]></description>
			<content:encoded><![CDATA[<p>The two keynotes at Devoxx 2011 yesterday by Henrik Ståhl and Cameron Purdy from Oracle and today by Google&#8217;s Tim Bray couldn&#8217;t have been more different. If that is all Oracle&#8217;s got to bring to the table then I fear they&#8217;re in big trouble&#8230;</p>
<p>While Henrik Ståhl showed at least some passion and inspiration (neatly hidden underneath the Scandinavian cover) Cameron Purdy seemed to be nearly falling asleep himself flipping through his overloaded Oracle marketing slides. That he brought a colleague on stage who demonstrated the &#8220;cloud features&#8221; &#8211; gosh, how I hate this over-hyped cloud stuff &#8211; of the upcoming Glassfish 4.0 to<em> him</em>, instead of the audience, was seriously odd.</p>
<p>Tim Bray might be as high profile at Google Android as Ståhl/Purdy are at Oracle but there was pure passion pouring out of his mouth. Passion for software, passion for code, passion for improvement &#8211; and he spoke for himself and much less for Google*. He was vibrant and inspiring. Also, he was very humble and particularly respectful towards the Android competitors. Not a single rant or joke about iPhone or Windows Mobile 7 which he expects to catch up to Apple/Google pretty soon.</p>
<p>Tim Bray @Devoxx 2011:</p>
<ol>
<li>&#8220;Information wants to be free.&#8221;</li>
<li>&#8220;The absence of women is the elephant in the living room. It must be discussed.&#8221; on the lack of women @Devoxx showing <a href="http://en.wikipedia.org/wiki/Banksy" target="_blank">Banksy</a>&#8216;s famous <a href="http://images.fanpop.com/images/image_uploads/red-elephant-banksy-338521_800_501.jpg" target="_blank" rel="lightbox[788]">red elephant photo</a></li>
<li>&#8220;If you are not working on mobile you are away from the action.&#8221;</li>
<li>&#8220;&#8230;wouldn&#8217;t you rather feed the poor, cloth the naked, cure the sick?&#8221; on why it&#8217;d be so much more important to develop apps for people in the third world rather than for us westerns who lead a lifestyle that lacks nothing (mobile Internet access dwarfs &#8220;cable-based&#8221; access particularly in underdeveloped countries)</li>
<li>&#8220;The importance of static type checking is proportional to the number of APIs your coding against, but inversely proportional to easyness of unit testing.&#8221; or so</li>
</ol>
<p>* I&#8217;m neither an Android developer, and I don&#8217;t intend to become one, nor is it the mobile platform of my choice. I&#8217;m all Apple <img src='http://www.frightanic.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/11/17/oracle-is-in-deep-trouble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oops, he did it again&#8230;</title>
		<link>http://www.frightanic.com/2011/11/13/oops-he-did-it-again/</link>
		<comments>http://www.frightanic.com/2011/11/13/oops-he-did-it-again/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 10:37:36 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[clean code]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=785</guid>
		<description><![CDATA[he = Uncle Bob it = writing a book about Clean Code I started reading &#8220;Clean Coder&#8221; the same day it arrived at my desk. Contrary to &#8220;Clean Code&#8221;, Uncle Bob&#8217;s previous book, it was supposed to about coding /practices/ rather than code. As such it should be about the the /behavior/ of engineers who [...]]]></description>
			<content:encoded><![CDATA[<p>he = Uncle Bob<br />
it = writing a book about Clean Code</p>
<p>I started reading &#8220;Clean Coder&#8221; the same day it arrived at my desk. Contrary to &#8220;Clean Code&#8221;, Uncle Bob&#8217;s previous book, it was supposed to about coding /practices/ rather than code. As such it should be about the the /behavior/ of engineers who strive to write clean code.</p>
<div class="wp-caption alignnone" style="width: 310px"><a href="http://www.amazon.com/gp/reader/0137081073/ref=sib_dp_kd/190-2343341-3724206#reader-link" target="_blank"><img class=" " title="Clean Coder by Robert C. Martin" src="http://ecx.images-amazon.com/images/I/51BSQqef%2B6L._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg" alt="Clean Coder by Robert C. Martin" width="300" height="300" /></a><p class="wp-caption-text">Clean Coder by Robert C. Martin</p></div>
<p>So, I for a few days I read chapter by chapter while commuting to and from work. It was a similar experience to reading &#8220;Clean Code&#8221;, very often I would think &#8220;Exactly! That&#8217;s it, nicely put.&#8221; because Uncle Bob&#8217;s believes and convictions are very much in line with my own. However, the longer I read the less interested I became. Finally, the book has been siting unfinished and untouched in my backpack for well over a month.</p>
<p>Why? Much more than in &#8220;Clean Code&#8221; Uncle Bob keeps repeating himself and if you&#8217;ve read some of his previous publications you know what to expect. Besides, there are way too many personal stories from his past that seem irrelevant (to me) for the purpose of the book.</p>
<p>If you have only little time, or little patience, I recommend you read at least the first chapter titled &#8220;professionalism&#8221;. In many ways it&#8217;s like a summary of the book.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/11/13/oops-he-did-it-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solving Maven install: &#8220;unzip: command not found&#8221;</title>
		<link>http://www.frightanic.com/2011/10/23/solving-maven-install-unzip-command-not-found/</link>
		<comments>http://www.frightanic.com/2011/10/23/solving-maven-install-unzip-command-not-found/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 19:52:29 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=779</guid>
		<description><![CDATA[With a newly set up Maven project I tried deploying the site using mvn site:deploy. The command kept failing with the following error Embedded error: Error performing commands for file transfer Exit code: 0 - bash: unzip: command not found for the longest time. I tried all kinds of funny things although I was 100% [...]]]></description>
			<content:encoded><![CDATA[<p>With a newly set up Maven project I tried deploying the site using <code>mvn site:deploy</code>. The command kept failing with the following error</p>
<pre>Embedded error: Error performing commands for file transfer
Exit code: 0 - bash: unzip: command not found</pre>
<p>for the longest time. I tried all kinds of funny things although I was 100% certain that I do have unzip in path. I was a bit embarresed when I finally realized that this error message was the result of the command executed over SSH on the <em>remote</em> host (Debian Linux) &#8211; the one the site was deployed to.</p>
<p>After that it was a piece of cake. Just had to install unzip on Linux using APT: <code>apt-get install unzip</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/10/23/solving-maven-install-unzip-command-not-found/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Learning DOT is&#8230;</title>
		<link>http://www.frightanic.com/2011/10/02/learning-dot-is/</link>
		<comments>http://www.frightanic.com/2011/10/02/learning-dot-is/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 13:02:02 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[DOT]]></category>
		<category><![CDATA[Graphviz]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=752</guid>
		<description><![CDATA[&#8230;not really learning DOT because it&#8217;s so simple &#8211; at least in its most basic form. I don&#8217;t understand why it took me so long to finally sit down and understand how the input for Graphviz works. What a glorious day today&#8230; You want to learn DOT, too? Wonderful, for a quick-start try this online [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230;not really <em>learning</em> <a href="http://en.wikipedia.org/wiki/DOT_language" target="_blank">DOT</a> because it&#8217;s so simple &#8211; at least in its most basic form. I don&#8217;t understand why it took me so long to finally sit down and understand how the input for <a href="http://en.wikipedia.org/wiki/Graphviz" target="_blank">Graphviz</a> works. What a glorious day today&#8230;</p>
<p>You want to learn DOT, too? Wonderful, for a quick-start try this online editor with preview: <a href="http://graphviz-dev.appspot.com/">http://graphviz-dev.appspot.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/10/02/learning-dot-is/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Maven hbm2ddl: fixing java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy</title>
		<link>http://www.frightanic.com/2011/08/06/maven-hbm2ddl-fixing-java-lang-arraystoreexception-sun-reflect-annotation-enumconstantnotpresentexceptionproxy/</link>
		<comments>http://www.frightanic.com/2011/08/06/maven-hbm2ddl-fixing-java-lang-arraystoreexception-sun-reflect-annotation-enumconstantnotpresentexceptionproxy/#comments</comments>
		<pubDate>Sat, 06 Aug 2011 13:33:33 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[hbm2ddl]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=736</guid>
		<description><![CDATA[Creating a DDL in the Maven build with the hibernate3-maven-plugin fails if you explicitly configure an array of javax.persistence.CascadeType values in your JPA annotations. The stacktrace is similar to javax.persistence.PersistenceException: [PersistenceUnit: spontacts] Unable to configure EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265) at org.codehaus.mojo.hibernate3.configuration.JPAComponentConfiguration.createConfiguration(JPAComponentConfiguration.java:28) ... Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy at sun.reflect.annotation.AnnotationParser.parseEnumArray(AnnotationParser.java:673) at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:462) Once I realized what the actual [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a DDL in the Maven build with the <a href="http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/" target="_blank">hibernate3-maven-plugin</a> fails if you explicitly configure an array of <a href="http://download.oracle.com/javaee/5/api/javax/persistence/CascadeType.html" target="_blank">javax.persistence.CascadeType</a> values in your JPA annotations. The stacktrace is similar to</p>
<pre class="brush:java">javax.persistence.PersistenceException: [PersistenceUnit: spontacts] Unable to configure EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
	at org.codehaus.mojo.hibernate3.configuration.JPAComponentConfiguration.createConfiguration(JPAComponentConfiguration.java:28)
...
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentExceptionProxy
	at sun.reflect.annotation.AnnotationParser.parseEnumArray(AnnotationParser.java:673)
	at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:462)</pre>
<p>Once I realized what the actual cause is, the fix was simple. Turns out that the CascadeType is not in the classpath when Maven runs the hbm2ddl goal. Hence you need to add a dependency to JPA to the hibernate3-maven-plugin:</p>
<pre class="brush:xml">&lt;plugin&gt;
	&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
	&lt;artifactId&gt;hibernate3-maven-plugin&lt;/artifactId&gt;
	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;org.hibernate.javax.persistence&lt;/groupId&gt;
			&lt;artifactId&gt;hibernate-jpa-2.0-api&lt;/artifactId&gt;
			&lt;version&gt;1.0.0.Final&lt;/version&gt;
		&lt;/dependency&gt;
	&lt;/dependencies&gt;
	&lt;executions&gt;
		...
	&lt;/executions&gt;
	&lt;configuration&gt;
		...
	&lt;/configuration&gt;
&lt;/plugin&gt;</pre>
<p>A solution to this exception in a different context was posted here: <a href="http://javahowto.blogspot.com/2008/10/solve-javalangarraystoreexception.html" target="_blank">http://javahowto.blogspot.com/2008/10/solve-javalangarraystoreexception.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/08/06/maven-hbm2ddl-fixing-java-lang-arraystoreexception-sun-reflect-annotation-enumconstantnotpresentexceptionproxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Git the hard way or command line vs. EGit</title>
		<link>http://www.frightanic.com/2011/02/06/learning-git-the-hard-way-or-command-line-vs-egit/</link>
		<comments>http://www.frightanic.com/2011/02/06/learning-git-the-hard-way-or-command-line-vs-egit/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 20:30:12 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=665</guid>
		<description><![CDATA[I&#8217;m in the process of teaching myself how to use Git. I&#8217;ve been using SVN for the last several few years and CVS before that. Precondition: I use the Eclipse IDE and it&#8217;s become really dear to me. So, I asked a nerdy colleague for advice: &#8220;Dude, has EGit reached a mature state or should [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of teaching myself how to use Git. I&#8217;ve been using SVN for the last several few years and CVS before that.</p>
<p>Precondition: I use the Eclipse IDE and it&#8217;s become really dear to me.</p>
<p>So, I asked a nerdy colleague for advice: &#8220;Dude, has EGit reached a mature state or should I learn command line Git?&#8221;<br />
The nerd says dryly: &#8220;Using the command line invigorates your personality.&#8221;</p>
<p>Ouch, message understood.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/02/06/learning-git-the-hard-way-or-command-line-vs-egit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to debug a Maven mojo with Eclipse</title>
		<link>http://www.frightanic.com/2011/02/04/how-to-debug-a-maven-mojo-with-eclipse/</link>
		<comments>http://www.frightanic.com/2011/02/04/how-to-debug-a-maven-mojo-with-eclipse/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 22:25:41 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[mojo]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=653</guid>
		<description><![CDATA[Checkout the mojo source code Run mvn install on the mojo Change to the project that uses the mojo for its build Run mvnDebug &#60;whatever options&#62; -&#62; Maven waits for a debugger to attach before executing Setup a new remote debugging configuration in Eclipse, using the plugin project for source and connecting to localhost:8000 (Maven [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>Checkout the mojo source code</li>
<li> Run mvn install on the mojo</li>
<li> Change to the project that uses the mojo for its build</li>
<li>Run <code>mvnDebug &lt;whatever options&gt;</code> -&gt; Maven waits for a debugger to attach before executing</li>
<li> Setup a new remote debugging configuration in Eclipse, using the plugin project for source and connecting to  <code>localhost:8000</code> (Maven tells you which port when you run <code>mvnDebug</code>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2011/02/04/how-to-debug-a-maven-mojo-with-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extra lazy one-to-many mapping with Hibernate</title>
		<link>http://www.frightanic.com/2010/11/21/extra-lazy-one-to-many-mapping-with-hibernate/</link>
		<comments>http://www.frightanic.com/2010/11/21/extra-lazy-one-to-many-mapping-with-hibernate/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 13:04:51 +0000</pubDate>
		<dc:creator>frightanic</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.frightanic.com/?p=611</guid>
		<description><![CDATA[Assume entity A has a one-to-many relationship to B. So, you&#8217;d have a method like A#getBs(). However, sometimes you might/will only need the number of Bs and not the entities themselves i.e. you need the count. However, if you called A#getBs()#getSize() you&#8217;d effectively initialize the collection and thereby loading entities into memory for no reason. [...]]]></description>
			<content:encoded><![CDATA[<p>Assume entity A has a one-to-many relationship to B. So, you&#8217;d have a  method like A#getBs(). However, sometimes you might/will only need the <em>number</em> of Bs and not the entities themselves i.e. you need the count. However, if you called A#getBs()#getSize()  you&#8217;d effectively initialize the collection and thereby loading entities  into memory for no reason.</p>
<p>Today I learned that Hibernate has an extra-lazy mode that detects such  cases. It issues the proper &#8220;select count(id) from A&#8221; SQL statement instead of &#8220;select &#8230; from A&#8221; in the  background: <a href="http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/annotations/LazyCollectionOption.html" target="_blank">@LazyCollection(LazyCollectionOption.EXTRA)</a></p>
<p>The enum&#8217;s JavaDoc is very terse but there&#8217;s a nice article here:  <a href="http://sites.google.com/a/pintailconsultingllc.com/java/hibernate-extra-lazy-collection-fetching">http://sites.google.com/a/pintailconsultingllc.com/java/hibernate-extra-lazy-collection-fetching</a> (also stresses the difference of list vs. bag semantics). If you happen  to have a copy of &#8220;<a href="http://www.manning.com/bauer2/" target="_blank">Java Persistence with Hibernate</a>&#8221; you&#8217;d find this  in chapter 13.1.3 on page 567.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.frightanic.com/2010/11/21/extra-lazy-one-to-many-mapping-with-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

