<?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>let x=x &#187; ejb</title>
	<atom:link href="http://www.crazymcphee.net/x/tag/ejb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.crazymcphee.net/x</link>
	<description>programming idiom and methodology</description>
	<lastBuildDate>Tue, 13 Jul 2010 21:56:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Does JPA kill the DAO Pattern?</title>
		<link>http://www.crazymcphee.net/x/2009/01/16/does-jpa-kill-the-dao-pattern/</link>
		<comments>http://www.crazymcphee.net/x/2009/01/16/does-jpa-kill-the-dao-pattern/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 12:30:41 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ejb]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[persistence]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=44</guid>
		<description><![CDATA[Oliver Gierke definitely thinks not. And I concur with him. A couple of years ago I got into an running battle with a developer at my old workplace as to whether the JPA architecture abstracted away enough of the persistence to justify eliminating the database layer. My answer was, and still is, certainly not! The [...]]]></description>
			<content:encoded><![CDATA[<p>Oliver Gierke <a href="http://www.olivergierke.de/wordpress/2009/01/se-radio-episode-121-or-mappers/">definitely thinks not</a>. And I concur with him.</p>
<p>A couple of years ago I got into an running battle with a developer at my old workplace as to whether the JPA architecture abstracted away enough of the persistence to justify eliminating the database layer. My answer was, and still is, <em>certainly not!</em></p>
<p>The simple answer to this question is another question &#8211; <em>What if you wanted to replace JPA?</em> The users of the data layer, lets call these objects the SessionLayer, need not, and should not know what sort of persistence layer you&#8217;re using. JPA does manage to abstract away some annoyances with choosing a specific transactional persistence technology just as Hibernate or Toplink. But what if you need to replace database access with a call to a web service? Convert the entire application to use Spring transactions? Send a non-transactional JMS message? Or just write the data in a <em>flat file</em>? </p>
<p>If you have an entirely separate data access layer, which encapsulates your data persistence methods from its users, there&#8217;s only one place to change. It&#8217;s clients need not ever know you made that change. You have <em>isolated the responsibility</em>. JPA, unencapsulated, encourages users of the data layer to consider the method of persistence. Use JPA underneath your data layer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/01/16/does-jpa-kill-the-dao-pattern/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>In which magic method naming is considered to be harmful</title>
		<link>http://www.crazymcphee.net/x/2009/01/16/inwhichmagicmethodnamingconsideredharmful/</link>
		<comments>http://www.crazymcphee.net/x/2009/01/16/inwhichmagicmethodnamingconsideredharmful/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 06:05:41 +0000</pubDate>
		<dc:creator>Scot Mcphee</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ejb]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[refactor]]></category>

		<guid isPermaLink="false">http://www.crazymcphee.net/x/?p=30</guid>
		<description><![CDATA[AKA EJB &#60;= 2.x Entities are a stupid idea stupidly implemented. A blast from the past. What idiot decided this was a good idea? public interface SomeEntity &#123; String getType&#40;&#41;; String getName&#40;&#41;; &#125; &#160; public interface SomeEntityHome extends EntityHome &#123; SomeEntity findBySomeData&#40;String name, String type&#41;; &#125; &#160; public class SomeEntityEjb implements SomeEntity, EntityBean &#123; public SomeEntity [...]]]></description>
			<content:encoded><![CDATA[<h3>AKA EJB &lt;= 2.<em>x</em> Entities are a stupid idea stupidly implemented.</h3>
<p>A blast from the past. What <em>idiot</em> decided this was a good idea?</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> SomeEntity <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">String</span> getType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> SomeEntityHome <span style="color: #000000; font-weight: bold;">extends</span> EntityHome <span style="color: #009900;">&#123;</span>
    SomeEntity findBySomeData<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name, <span style="color: #003399;">String</span> type<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SomeEntityEjb <span style="color: #000000; font-weight: bold;">implements</span> SomeEntity, EntityBean <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> SomeEntity ejbFindBySomeData<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name, <span style="color: #003399;">String</span> type<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// some cogent implementation here</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">type</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Let&#8217;s refactor SomeEntityEjb.java shall we? Change that ejbFind method. Then spend the next half hour figuring out what you did wrong &#8211; Jboss doesn&#8217;t deploy the EJBs! Grep the code-base for &#8220;ejbFindBySomeData&#8221; &#8230; there&#8217;s got to be a magic specification of that method <em>somewhere</em> in the code. Nothing found?!  Hmm it&#8217;s been years since I&#8217;ve dealt with &lt; 3.0 Entity Beans. Struggle to recall the EJB specification .. what are the magical matching methods in the Home interface? <em>Oh yeah, that&#8217;s right!</em>  EntityHome has <span style="text-decoration: underline;">findXXX</span>, EntityBean has <span style="text-decoration: underline;">ejbFindXXX</span>. <em>Why, in god&#8217;s name, why?</em></p>
<p>No wonder people got dead-set against EJBs (meaning Entity EJBs) back in 2001 or 2002. Ahhh give me Spring and Hibernate anyday. And remember -<em> parallel magic method naming is a stupid idea - </em>especially in a statically typed language that is supposed to let the compiler do the hard work for you. Jesus kill the people who invented this. Please.</p>
<p>I wish I had the scope just to remove all these Entities &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.crazymcphee.net/x/2009/01/16/inwhichmagicmethodnamingconsideredharmful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
