<?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>Ray Tsang's Blog</title>
	<atom:link href="http://saturnism.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://saturnism.wordpress.com</link>
	<description>More Random Ramblings</description>
	<lastBuildDate>Fri, 16 Jun 2006 20:53:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='saturnism.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ray Tsang's Blog</title>
		<link>http://saturnism.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://saturnism.wordpress.com/osd.xml" title="Ray Tsang&#039;s Blog" />
	<atom:link rel='hub' href='http://saturnism.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Prototype</title>
		<link>http://saturnism.wordpress.com/2006/06/16/prototype/</link>
		<comments>http://saturnism.wordpress.com/2006/06/16/prototype/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 23:30:54 +0000</pubDate>
		<dc:creator>saturnism</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[EJB3]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[POJO]]></category>
		<category><![CDATA[raills]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[springframework]]></category>
		<category><![CDATA[stripes]]></category>
		<category><![CDATA[Technology and Software]]></category>

		<guid isPermaLink="false">https://saturnism.wordpress.com/2006/06/16/prototype/</guid>
		<description><![CDATA[I have been in process of moving from Taiwan back to California recently. I&#39;m finally settled in for now. My partner and I finally had acquired some hours to work on the Stripes on Rails idea. The prototype includes features: Maven2 Webtype Plugin Maven2 Stripes-on-Rails Configuration Archetype Corresponding Templates Other quirks Override default templates Inherit [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=6&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been in process of moving from Taiwan back to California recently.  I&#39;m finally settled in for now.  My partner and I finally had acquired some hours to work on the <a href="http://saturnism.wordpress.com/2006/05/17/stripes-on-rail/">Stripes on Rails</a> idea.  The prototype includes features:</p>
<ul>
<li>Maven2 Webtype Plugin</li>
<li>Maven2 Stripes-on-Rails Configuration Archetype</li>
<li>Corresponding Templates</li>
<li>Other quirks
<ul>
<li>Override default templates</li>
<li>Inherit configuration to make new configuration</li>
<li>Add webtype to existing projects</li>
</ul>
</li>
</ul>
<p><span id="more-6"></span><b>Webtype</b></p>
<p>We ended up calling the project Webtype (as oppose to archetype).  A webtype is for now geared towards Java web-based applications.  A webtype consists of an architecture configuration and corresponding templates.  In the Stripes-on-Rails configuration, it includes dependencies such as Stripes, Spring, Hibernate, EJB3 Annotation, and supporting base classes such as BaseCRUDAction, BaseCRUDManager, BaseDAO to scaffold default CRUD behaviors.  It would then use the templates to generate the CRUD features from a domain entity, including JSP pages, Spring configuration, Hibernate configuration, etc.</p>
<p>How to Use?</p>
<ol>
<li><i>webtype</i> com.acme.example webapp # create a new webapp/ directory with a project structure</li>
<li><i>generate</i> Person # generate CRUD feature and configuration</li>
<li><i>export</i> derby # export database schema to Apache Derby database</li>
<li><i>initdata</i> derby # load initial data from xml into Apache Derby database</li>
<li><i>run</i> # execute the web server</li>
<li>http://localhost:9090/webapp/Person.action # view the webapp!</li>
</ol>
<p>The web server will check for class and JSP updates to hot deploy changes.</p>
<p><b>Play Nice with Existing Project</b></p>
<p>Webtype is a generic Maven2 plugin that looks for a webtype.xml descriptor either in the current project or in the classpath.  Suppose there is an existing Maven2 project that needed quick code generation, one can easily add the descriptor and the corresponding templates to src/webtype/, that&#39;s all!  It doesn&#39;t really care what architecture you have underneath, so long the generated code works for you.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/saturnism.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/saturnism.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saturnism.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saturnism.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saturnism.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saturnism.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saturnism.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saturnism.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saturnism.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saturnism.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=6&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saturnism.wordpress.com/2006/06/16/prototype/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e0c801ac1a5d0512bb9774ab158d06d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saturnism</media:title>
		</media:content>
	</item>
		<item>
		<title>Stripes on Rail</title>
		<link>http://saturnism.wordpress.com/2006/05/17/stripes-on-rail/</link>
		<comments>http://saturnism.wordpress.com/2006/05/17/stripes-on-rail/#comments</comments>
		<pubDate>Wed, 17 May 2006 14:40:43 +0000</pubDate>
		<dc:creator>saturnism</dc:creator>
				<category><![CDATA[EJB3]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[POJO]]></category>
		<category><![CDATA[raills]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[springframework]]></category>
		<category><![CDATA[stripes]]></category>
		<category><![CDATA[Technology and Software]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://saturnism.wordpress.com/2006/05/17/stripes-on-rail/</guid>
		<description><![CDATA[I have yet to become a Ruby fan. But it does make me, a Java developer, envy some of its perceived simplicity. I do want a framework that is flexible and configurable. I do want my Java compiler and IDE catching errors for me at compile time or before that. There are a few frameworks [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=5&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have yet to become a Ruby fan.  But it does make me, a Java developer, envy some of its perceived simplicity.  I do want a framework that is flexible and configurable.  I do want my Java compiler and IDE catching errors for me at compile time or before that.  There are a few frameworks out there currently that put together many other frameworks and has the ability to generate CRUD code: JBoss IDE for JBoss Seam?  Appfuse&#39;s Appgen for variety of frameworks.</p>
<p>But sometimes I can&#39;t help but to think if we can get any simpler?  I say yes we can!   How simple can we get? Obviously, from the basic domain entity classes, we should be able to generate at runtime all the things we ever need for basic CRUD operations (including screen, sql).  This has been done and that&#39;s what made other frameworks (even language) popular.  However, we are Java developers.  We want to do this <i>while</i> maintaining good multi-teired POJO architecture and its flexibility!</p>
<p><span id="more-5"></span>For this, we need to look in to quite a few currently available technology:</p>
<ol>
<li>Spring</li>
<li>Stripes</li>
<li>Hibernate</li>
<li>EJB3</li>
<li>Maven2</li>
</ol>
<p><b>Spring</b></p>
<p>What!  Wasn&#39;t this suppose to be easy?  Do we really have to write XML?  The answer is of course not!  Well, maybe for a few configuration issues.  But that&#39;s another issue we&#39;ll deal with in Maven2 profile.  But we do need Spring to tie all the frameworks together while maintaing flexibility in the future when necessary.  The default Spring configurations can be encapsulated in a Jar file so that no body really need to edit it for the default behavior.  Moreover, we can use Acegi Security for authentication.  Of course, this default confdiguration is encapsulated as well.</p>
<p><b>Stripes</b></p>
<p>Stripes is a light and simple framework that takes advantages of Java 5 Annotations while keeping away from what I call &quot;annotation hell&quot;.  With Stripes, we can easily extend its ActionBean and ActionResolver facilities.  What this means is that we can creat a GenericCRUDActionBean like:</p>
<p>public interface GenericsCRUDActionBean&lt;T&gt; {</p>
<p>public T getEntity(); // single</p>
<p>public void setEntity(T entity);</p>
<p>public List&lt;T&gt; getEntities(); // multiple entities, such as query results</p>
<p>public setEntities(List&lt;T&gt; entities);</p>
<p>public Resolution save(); // event</p>
<p>public Resolution query(); // event</p>
<p>public Resolution delete(); // event</p>
<p>}</p>
<p>ActionResolver can be used to automatically determine what ActionBean is to be instantiated for a URI request.   For example, /context/Person.action will automatically instantiate a new GenericsCRUDActionBean&lt;T&gt; and serve the incoming request.</p>
<p>Moreover, quite remarkable jobs has been done with Stripes form generation by community members that can generate HTML forms from ActionBeans.  Associations are also taken into account.  We can further extend this to use DOJO widgets for property types such as Date (DOJO date picker).  Moroever, we can also generate DOJO validation attributes from Stripes&#39; Validation annotation or other validation oriented annotations.</p>
<p><b>EJB3</b></p>
<p>To stay away from XML configuration, we can use EJB3 annotations for entity beans, a.k.a. domain classes.  To further staying away from EJB3 descriptors, we can use Hibernate for ORM.  Not only that,  we dont&#39; even need to write hibernate.cfg.xml to declare what domain classes should be mapped!  The reason is that we can resolve EJB3 annotated entity beans the same way Stripes resolve its ActionBeans.  Stripes annotation resolver utility can be easily integrated into a new Spring bean that extends AnnotationHibernateSessionFactoryBean.</p>
<p><b>Hibernate</b></p>
<p>Generics DAO pattern already exist for Hibernate.  Thus, there can be a class GenericsDAO&lt;T&gt; that looks like:</p>
<p>public interface GenericsDAO&lt;T, ID&gt; {</p>
<p>public void save(T entity);</p>
<p>public void findByExample(T example);</p>
<p>public void delete(ID id);<br />
}</p>
<p><b>What about the Service Layer?</b></p>
<p>By default, similar GenericsManager&lt;T, ID&gt; can be implemented that delegates to GenericsDAO&lt;T, ID&gt;.  Although not strictly necessary, but it may help enforce some architectural consistency if one decided to get away from these Generics stuff.  After all, they are generic!</p>
<p><b>Maven2</b></p>
<p>Maven2 can help in the overall build, test, and deploy process.  Specifically, I&#39;m looking at Maven2 in the following areas:</p>
<ol>
<li>Configuration (profile.xml)</li>
<li>Build and Packaging (into deployable WAR file)</li>
<li>Dependency (let&#39;s see&#8230; stripes, hibernate, ejb3, spring, acegisecurity, &#8230;)</li>
<li>Testing and Reports (All kinds of reports in test results, code quality, documentations, todos, &#8230;)</li>
<li>Archetype (Who wants to rewrite all these?  Create the whole project from the archetype!)</li>
<li>Execdution (Jetty6 plugin seems very promising.  One can execute a web project using just one command)</li>
</ol>
<p>Basically, with Maven2, this is what we do to get started:</p>
<ol>
<li>mvn archetype:create &#8230;&#8230;. (create a new project with all the default pom.xml, directory structure, dependencies, report requirements, site generations, packaging details, and of course, Jetty6 plugin to execute the whole thing for immediate results)</li>
<li>Create a domain entity class, e.g. a Person class.</li>
<li>mvn jetty6:run (compile and run the application! go to http://localhost:8080/project/Person.action to see it in action)</li>
</ol>
<p>That should be the MOST that one should need to do.  Database generation and initial data loading can be configured to execute at deployment/initialization time.  These can also be done via command line such as mvn hibernate:schemaExport, mvn dbunit:loadData (via corresponding plugins).</p>
<p>Now suppose we make this even simpler:</p>
<ol>
<li>createProject com.nooton.webapp my-webapp</li>
<li>@Entity public class Person { @Id public Long id; public String name; public String address; }</li>
<li>runProject</li>
<li>http://localhost:9090/my-webapp/Person.action</li>
</ol>
<p>That&#39;s all.</p>
<p><b>Abstract DAO</b></p>
<p>In this architecture, one is free to implement their own DAO, Manager, or ActionBean.  We can make the DAO implementation job easier by introducing Abstract DAO annotation from <a href="http://saturnism.wordpress.com/2006/04/03/spring-and-dao-w-annotation/">previous idea</a> and <a href="http://saturnism.wordpress.com/2006/05/13/spring-and-dao-w-annotation-it-works/">implementation</a>.  So in case one really needs to do some custom queries, one can annotate the query to an abstract method, rather than getting into Hibernate details (getHibernateTemplate()&#8230; throw exceptions&#8230;)&nbsp;</p>
<p><b>Conclusion</b></p>
<p>Whew!  There are obviously many frameworks that would need to be integrated.  But the good news is, most of the integration are probably done daily for a new project based with Spring, Hibernate, and similar tools.  While this &quot;framework&quot; can allow quick implementations of simple CRUD web applications, it is based on the entire POJO stack that can be easily extended to the extent that any other similar project structure can extend to.   It does not pose any restrictions on the entire application coding &quot;convention&quot;.  In fact, if one really want to use another framework for any layer, it is possible to completely swap the entire layer out with Spring configuration.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/saturnism.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/saturnism.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saturnism.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saturnism.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saturnism.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saturnism.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saturnism.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saturnism.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saturnism.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saturnism.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=5&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saturnism.wordpress.com/2006/05/17/stripes-on-rail/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e0c801ac1a5d0512bb9774ab158d06d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saturnism</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring and DAO w/ Annotation &#8211; It works!</title>
		<link>http://saturnism.wordpress.com/2006/05/13/spring-and-dao-w-annotation-it-works/</link>
		<comments>http://saturnism.wordpress.com/2006/05/13/spring-and-dao-w-annotation-it-works/#comments</comments>
		<pubDate>Fri, 12 May 2006 17:31:36 +0000</pubDate>
		<dc:creator>saturnism</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[EJB3]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[POJO]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[springframework]]></category>
		<category><![CDATA[Technology and Software]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://saturnism.wordpress.com/2006/05/13/spring-and-dao-w-annotation-it-works/</guid>
		<description><![CDATA[I finally got some time to implement the idea that I mentioned in previous blog. After struggling for hours with Spring AOP, I realized I needed CGLIB to proxy abstract class! It took me a while to learn a bit about Spring&#39;s AOP framework. After hours of struggling with words such as Attribute, Definition, Config, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=4&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I finally got some time to implement the idea that I mentioned in <a href="http://saturnism.wordpress.com/2006/04/03/spring-and-dao-w-annotation/" title="Spring and DAO w/ Annotation" target="_blank">previous blog</a>.  After struggling for hours with Spring AOP, I realized I needed CGLIB to proxy abstract class!</p>
<p><span id="more-4"></span>It took me a while to learn a bit about Spring&#39;s AOP framework.  After hours of struggling with words such as Attribute, Definition, Config,  Advisor, Source, ObjectSourceDefinition, I finally realized that those were not the problems.</p>
<p>Apparently Spring AOP can only proxy a real instantiated object, i.e. non-abstract class.  But the idea is to use the abstract class and let someone else implement it using information provided with @HQL annotation.</p>
<p>So I switched to CGLIB, setting super class to the abstract class, and intercept calls to abstract methods that are annotated.</p>
<p>This is what I get so far&#8230;.</p>
<p>DAO Code:</p>
<blockquote>
<pre><code><font size="-2">
public abstract class PersonDAOHibernate
  extends HibernateDaoSupport
  implements PersonDAO
{
  @HQL(&quot;from Person p where p.name = :arg1&quot;)
  public abstract List&lt;Person&gt; findByName(String name);
  @HQL(&quot;from Person&quot;)
  public abstract List&lt;Person&gt; findAll();
}
</font></code></pre>
</blockquote>
<p>Because the method argument names are not accessible in compiled code, I had the resolve to naming by argument index numbers (starting from 1). I think I&#39;ll also  add argument/parameter level annotations that can specify parameter names:</p>
<blockquote>
<pre><code><font size="-2">
@HQL(&quot;from Person p where p.name = :name&quot;);
public abstract List findByName(@NamedParam(&quot;name&quot;) String name);
</font></code></pre>
</blockquote>
<p>Right now it recognizes return types of List and of the domain class for select/find operations.  For updates, it recognizes return types of void and integer (for returning counts)</p>
<p>The Spring configuration currently looks like the following:</p>
<blockquote>
<pre><code><font size="-2">
&lt;bean id=&quot;personDao&quot;
  class=&quot;com.nooton.spring.dao.hibernate3.annotation
    .AnnotationHibernateDAOProxyFactoryBean&quot;&gt;
  &lt;property name=&quot;targetClass&quot;
    value=&quot;dao.hibernate.PersonDAOHibernate&quot;/&gt;
  &lt;property name=&quot;sessionFactory&quot;
    ref=&quot;sessionFactory&quot;/&gt;
&lt;/bean&gt;
</font></code></pre>
</blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/saturnism.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/saturnism.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saturnism.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saturnism.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saturnism.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saturnism.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saturnism.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saturnism.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saturnism.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saturnism.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=4&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saturnism.wordpress.com/2006/05/13/spring-and-dao-w-annotation-it-works/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e0c801ac1a5d0512bb9774ab158d06d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saturnism</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring and DAO w/ Annotation</title>
		<link>http://saturnism.wordpress.com/2006/04/03/spring-and-dao-w-annotation/</link>
		<comments>http://saturnism.wordpress.com/2006/04/03/spring-and-dao-w-annotation/#comments</comments>
		<pubDate>Mon, 03 Apr 2006 05:46:30 +0000</pubDate>
		<dc:creator>saturnism</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[EJB3]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[POJO]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[Software development]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Technology and Software]]></category>

		<guid isPermaLink="false">https://saturnism.wordpress.com/2006/04/03/spring-and-dao-w-annotation/</guid>
		<description><![CDATA[Although EJB is moving forward to 3.0, and everyone seems to enjoy the POJO ORM stuff. I do miss some EJB 2.0 features. Particularly, being able to use the ejbSelect and finder methods! With xdoclet, one could easily annotate a method with its corresponding query. /** * @ejb.select query=&#34;....&#34; */ public abstract Collection ejbSelectWithKey(String key) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=3&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Although EJB is moving forward to 3.0, and everyone seems to enjoy the POJO ORM stuff.  I do miss some EJB 2.0 features.  Particularly, being able to use the ejbSelect and finder methods!  With xdoclet, one could easily annotate a method with its corresponding query.</p>
<blockquote>
<pre><code><font size="-2">
/**
  * @ejb.select query=&quot;....&quot;
  */
public abstract Collection ejbSelectWithKey(String key)
  throws FinderException;
</font></code></pre>
</blockquote>
<p>Although it seems like named queries are to replace the use of this kind of methods.  I still enjoyed the fact that the method is, afterall, a Java method.  The Java language can provide name, parameter, and type checkings to this method, where named queries can&#39;t.</p>
<p>I could imaging something similar w/ Spring and DAO, and some simple AOP/proxy to achieve the following:</p>
<p><span id="more-3"></span></p>
<blockquote>
<pre><code><font size="-2">
public abstract class PersonDAOHibernate implements PersonDAO
{
  @HQL(&quot;from Person p where p.id = :id&quot;);
  @InitializeProperties({&quot;accounts&quot;, &quot;projects&quot;});
  public abstract Person getById(Long id)
    throws DataAccessException;
  @HQL(&quot;from Person p where p.age &gt; 20&quot;);
  @Paged(pageSize = 10);
  public abstract Pager selectQualifiedAdults()
    throws DataAccessException;
  @HQL(&quot;from Person p where p.name like &#39;%:name%&#39;&quot;)
  @Paged(pageSize = 15);
  public abstract Pager selectByNameLike(String name)
    throws DataAccessException;
  @HQL(namedQuery=&quot;person.ageGreaterThan&quot;)
  @Paged
  public abstract Pager selectByAgeGreaterThanPaged(
    Integer age, int pageSize)
    throws DataAccessException;
  @HQL(namedQuery=&quot;person.ageGreaterThan&quot;)
  @PagedList
  public abstract List selectByAgeGreaterThanList(
    Integer age, int pageSize, int page)
    throws DataAccessException;
  @HQL(namedQuery=&quot;person.ageGreaterThan&quot;)
  @PagedList
  public abstract PagedList selectByAgeGreaterThanList(
    Integer age, int pageSize, int page)
    throws DataAccessException;
}
</font></code></pre>
</blockquote>
<p>Different implementations can use different annotation for the queries e.g. @SQL, @EQL, etc.  Not only can it embed a query, it can also link to named queries.</p>
<p>Without the Open Session In View pattern, it is necessary to load all the data that is required in upper tiers callers.  There is a feature in XDoclet for EJB 2.0 to generate value objects that does this pretty well.  However, in the recent development of ORM, it seems there is a need to manually initialize the lazily-loaded fields for each DAO methods (if not using Open Session In View).  In this example, fields initialization can be explicitly specified using @InitializeProperties.</p>
<p>Lastly, when the query string and parameters are known, it can auto-magically create a Pager object, which can dynamically load a page of items when called.</p>
<p>Updated May 13, 2006 &#8211; See <a href="//saturnism.wordpress.com/2006/05/13/spring-and-dao-w-annotation-it-works/">here</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/saturnism.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/saturnism.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saturnism.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saturnism.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saturnism.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saturnism.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saturnism.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saturnism.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saturnism.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saturnism.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=3&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saturnism.wordpress.com/2006/04/03/spring-and-dao-w-annotation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e0c801ac1a5d0512bb9774ab158d06d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saturnism</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://saturnism.wordpress.com/2006/04/03/hello-world/</link>
		<comments>http://saturnism.wordpress.com/2006/04/03/hello-world/#comments</comments>
		<pubDate>Mon, 03 Apr 2006 05:26:05 +0000</pubDate>
		<dc:creator>saturnism</dc:creator>
				<category><![CDATA[flickr]]></category>
		<category><![CDATA[Random Ramblings]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hello World! After my first contact w/ Flickr just a week ago, I decided to give blogging a try as well. www.flickr.com More of saturnism&#39;s photos<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=1&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello World!  After my first contact w/ <a href="http://www.flickr.com/photos/saturnism/">Flickr</a> just a week ago, I decided to give blogging a try as well.</p>
<table border="0" cellpadding="0" cellspacing="10">
<tr>
<td><a href="http://www.flickr.com">www.<b>flickr</b>.com</a></p>
<table border="0" cellpadding="0" cellspacing="10">
<tr>
<td align="center" valign="center">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10"><a href="http://www.flickr.com/photos/saturnism/"><img src="http://static.flickr.com/49/buddyicons/52923129@N00.jpg?1143387190" alt="saturnism&#39;s photos" align="left" height="48" width="48" /></a></td>
<td>More of <a href="http://www.flickr.com/photos/saturnism/">saturnism&#39;s photos</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p><!-- End of Flickr Badge --></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/saturnism.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/saturnism.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/saturnism.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/saturnism.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/saturnism.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/saturnism.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/saturnism.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/saturnism.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/saturnism.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/saturnism.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=saturnism.wordpress.com&amp;blog=174192&amp;post=1&amp;subd=saturnism&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://saturnism.wordpress.com/2006/04/03/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5e0c801ac1a5d0512bb9774ab158d06d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">saturnism</media:title>
		</media:content>

		<media:content url="http://static.flickr.com/49/buddyicons/52923129@N00.jpg?1143387190" medium="image">
			<media:title type="html">saturnism&#039;s photos</media:title>
		</media:content>
	</item>
	</channel>
</rss>
