<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/"
>

<channel>
	<title>Solution Hacker &#187; hibernate</title>
	<atom:link href="http://www.solutionhacker.com/tag/hibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solutionhacker.com</link>
	<description>This blog provides solutions for enterpreneurs!</description>
	<lastBuildDate>Mon, 06 Feb 2012 07:19:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=323</generator>
<!-- podcast_generator="Blubrry PowerPress/2.0.4" -->
	<itunes:summary>This blog provides solutions for enterpreneurs!</itunes:summary>
	<itunes:author>Solution Hacker</itunes:author>
	<itunes:explicit>no</itunes:explicit>
	<itunes:image href="http://www.solutionhacker.com/wp-content/plugins/powerpress/itunes_default.jpg" />
	<itunes:subtitle>This blog provides solutions for enterpreneurs!</itunes:subtitle>
	<image>
		<title>Solution Hacker &#187; hibernate</title>
		<url>http://www.solutionhacker.com/wp-content/plugins/powerpress/rss_default.jpg</url>
		<link>http://www.solutionhacker.com</link>
	</image>
		<item>
		<title>Hibernate vs iBatis</title>
		<link>http://www.solutionhacker.com/implement-your-idea/build-your-website/hibernate-vs-ibatis/</link>
		<comments>http://www.solutionhacker.com/implement-your-idea/build-your-website/hibernate-vs-ibatis/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 18:58:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Site Building]]></category>
		<category><![CDATA[data warehouse]]></category>
		<category><![CDATA[etl]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[reporting]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=216</guid>
		<description><![CDATA[<p><strong>Hibernate </strong>is great. However, I don't see it fits all the data access requirements. At its core, it is an <strong>ORM </strong>tool that helps you to map your <strong>object model</strong> to <strong>relational model</strong>. If you have full control of your relational model and perform lots of <strong>CRUD</strong> operations, it is certainly a great tool for you. Its transparent persistence, 2 level caching, dirty checking, lazy/ eager data retrieval and sql generation indeed can save us lots of development time. However, one tool doesn't fit all !! Why not?</p>
<p>In my current company, I have created a reporting tool that interfaces with dimensional model in data warehouse. In this setting, you will deal with <strong>star schema</strong> with <strong>denormalized dimensions</strong>.&#160; Often time, I need to tune the query performance via looking into explain plan. Without full control of SQL, my job will be hard to achieve. Apart from that, reporting tool often issues read-only set based queries to the data warehouse. The resultset returned doesn't fit into my OO model at all. Again, Hibernate just doesn't fit in. People in my company argue that I should use <strong>named query</strong> in Hibernate for the sake of sticking with the standard. I am like ok, whatever... I have known a tool called <strong>iBatis </strong>that I can achieve my job cleanly. Why the hell I would have motivation to try named query that basically a way to by-pass the ORM model to query database. What benefit I will get from this? The cache? We are using ETL to update our fact and dimension in the data warehouse, not by my reporting app. Unless the ETL throws me an event when the update cycle is finished so I can flush my cache, I simply don't think it gives me lots of help.</p>
<p>Anyway, it is just my own little perspective. You don't have to agree with me. The point here is not that I don't like Hibernate but I don't like to be pushed to use it only because it is "standard" to someone. If Hibernate could help me to construct my sql based on user input, stream my result directly to my presentation layer, populate my model automatically based on mapping I provided, detect data warehouse changes and take care my cache, then I am more happy to adopt it in my reporting app. Otherwise, I would not be eager to dump my <strong>iBatis </strong>DAO layer unless I get no choice under the political game.</p>
<h2>Reference</h2>
<ol>
    <li><a href="http://www.nofluffjuststuff.com/media.jsp?id=19">http://www.nofluffjuststuff.com/media.jsp?id=19</a></li>
    <li><a href="http://www.javalobby.org/articles/hibernate-query-101/">http://www.javalobby.org/articles/hibernate-query-101/</a></li>
    <li><a href="http://www.javabeat.net/tips/108-how-to-use-named-parameters-and-named-query-i.html">How to use named parameters and named query in Hibernate?</a></li>
    <li><a href="http://www.ibm.com/developerworks/java/library/j-genericdao.html">Don't repeat your DAO</a>&#160;</li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>Hibernate </strong>is great. However, I don&#8217;t see it fits all the data access requirements. At its core, it is an <strong>ORM </strong>tool that helps you to map your <strong>object model</strong> to <strong>relational model</strong>. If you have full control of your relational model and perform lots of <strong>CRUD</strong> operations, it is certainly a great tool for you. Its transparent persistence, 2 level caching, dirty checking, lazy/ eager data retrieval and sql generation indeed can save us lots of development time. However, one tool doesn&#8217;t fit all !! Why not?</p>
<p>In my current company, I have created a reporting tool that interfaces with dimensional model in data warehouse. In this setting, you will deal with <strong>star schema</strong> with <strong>denormalized dimensions</strong>.&#160; Often time, I need to tune the query performance via looking into explain plan. Without full control of SQL, my job will be hard to achieve. Apart from that, reporting tool often issues read-only set based queries to the data warehouse. The resultset returned doesn&#8217;t fit into my OO model at all. Again, Hibernate just doesn&#8217;t fit in. People in my company argue that I should use <strong>named query</strong> in Hibernate for the sake of sticking with the standard. I am like ok, whatever&#8230; I have known a tool called <strong>iBatis </strong>that I can achieve my job cleanly. Why the hell I would have motivation to try named query that basically a way to by-pass the ORM model to query database. What benefit I will get from this? The cache? We are using ETL to update our fact and dimension in the data warehouse, not by my reporting app. Unless the ETL throws me an event when the update cycle is finished so I can flush my cache, I simply don&#8217;t think it gives me lots of help.</p>
<p>Anyway, it is just my own little perspective. You don&#8217;t have to agree with me. The point here is not that I don&#8217;t like Hibernate but I don&#8217;t like to be pushed to use it only because it is &#8220;standard&#8221; to someone. If Hibernate could help me to construct my sql based on user input, stream my result directly to my presentation layer, populate my model automatically based on mapping I provided, detect data warehouse changes and take care my cache, then I am more happy to adopt it in my reporting app. Otherwise, I would not be eager to dump my <strong>iBatis </strong>DAO layer unless I get no choice under the political game.</p>
<h2>Reference</h2>
<ol>
<li><a href="http://www.nofluffjuststuff.com/media.jsp?id=19">http://www.nofluffjuststuff.com/media.jsp?id=19</a></li>
<li><a href="http://www.javalobby.org/articles/hibernate-query-101/">http://www.javalobby.org/articles/hibernate-query-101/</a></li>
<li><a href="http://www.javabeat.net/tips/108-how-to-use-named-parameters-and-named-query-i.html">How to use named parameters and named query in Hibernate?</a></li>
<li><a href="http://www.ibm.com/developerworks/java/library/j-genericdao.html">Don&#8217;t repeat your DAO</a>&#160;</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/implement-your-idea/build-your-website/hibernate-vs-ibatis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wiring up Flex, Mate, BlazeDS, Spring, Hibernate and MySQL with Maven 2 &#8211; Part 1</title>
		<link>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/</link>
		<comments>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 10:50:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[5. Fun]]></category>
		<category><![CDATA[6. Uncategorized]]></category>
		<category><![CDATA[Site Building]]></category>
		<category><![CDATA[Team]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[application stack]]></category>
		<category><![CDATA[BlazeDS]]></category>
		<category><![CDATA[build process]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jetty plugin]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=199</guid>
		<description><![CDATA[<h2>Introduction</h2>
<p>This article is written on top of the great work that&#160;<strong>Sébastien Arbogast </strong>has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference.</p>
<ol>
    <li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt1.html">The Flex, Spring, and BlazeDS full stack – Part 1: Creating a Flex module</a></li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt2.html">The Flex, Spring and BlazeDS full stack – Part 2: Writing the to-do list server</a></li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt3.html">The Flex, Spring and BlazeDS full stack – Part 3: Putting the application together</a></li>
</ol>
<p>I have found Sebastien's work as a good foundation for my own project. To contribute back to the community, I will write a series of articles to show you how can customize and extend the todolist sample.</p>
<p><u>What is in the Part 1 of the series...</u></p>
<ol>
    <li>Enhancements on the <strong>Maven </strong>build process
    <ul>
        <li>Leverage <strong>RSL </strong>to factor our the framework swc, so the size of the application swf will be reduced. Apart from that, I also take advantage of <strong>Flash Player Cache</strong> that is available after version 9 update 3 to cache the framework libraries.</li>
        <li>Clean up the Flex and <strong>BlazeDS </strong>dependencies in POM as the latest version of the sdk is available and the BlazeDS dependencies are officially available.</li>
        <li>Include some common reports for maven site generation</li>
        <li>Embed <strong>Jetty</strong> web server in the build process for quick deployment and testing</li>
    </ul>
    </li>
    <li>Document how to get the sample up on <strong>Eclipse </strong>for development<strong><br />
    </strong></li>
    <li>Use <strong>Mate </strong>as Flex framework
    <ul>
        <li>Restructure ToDoList sample to leverage Mate framework</li>
        <li>Factor out Mate as RSL and integrate it with Maven build process via Flex-mojo plugin.</li>
    </ul>
    </li>
</ol>
<p><u>What are in the coming articles...</u></p>
<ol>
    <li>In part 2 of this series, I will show you how to use flex-mojo to build a modular Flex application.</li>
    <li>In part 3 of this series, I will show you how to test your flex app via FlexUnit (Unit test) and FlexMonkey (Functional test)</li>
    <li>In part 4 or this series, I will work on server side. I am planning to add monitoring, caching and security to the server side.</li>
</ol>
<p><!--more--><!--more--></p>
<h2><!--more-->Review "ToDoList" sample</h2>
<p>Before I start my journey, let me highlight what Sebastien has done first:</p>
<ol>
    <li>Sebastien's sample demonstrates how to use Maven as a build process. There are 3 parts or subprojects in his sample. They are:<br />
    <ul>
        <li><strong>todolist-config</strong> (configuration files shared by other subprojects)</li>
        <li><strong>todolist-ria </strong>(Flex frontend)</li>
        <li><strong>todolist-web</strong> (Server side that supports the Frontend)</li>
    </ul>
    </li>
    <li>All these subprojects are considered as <strong>modules </strong>of the main project (root POM). Finally, they are combined together into war artifact and ready to deploy to Tomcat or other J2EE webapp server.</li>
    <li>Flex frontend and backend communicate through a binary RPC protocol - <strong>AMF</strong>. AMF is considered to be the simplest and fastest remoting approach available in Flex. Recently, Adobe has released BlazeDS as an open source implementation of AMF spec. In this sample, <strong>BlazeDS </strong>is used. To use BlazeDS, there are few things you need to do:<br />
    <ul>
        <li>Externalize your POJO service via BlazeDS. This sample shows you how to integrate BlazeDS with Spring</li>
        <li>Make BlazeDS endpoints availabe to the Net via Servlet.</li>
        <li>Have frontend and backend shared the same BlazeDS configuration files.</li>
    </ul>
    </li>
    <li>In this sample, you can also find out how to use <strong>flex-mojo</strong> maven plugin to compile the Flex frontend code into swf. Apart from <a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">flex-mojo plugin</a>, there are other two good plugins worth to mention:<br />
    <ul>
        <li><strong>maven-assembly-plugin </strong>- can be used to bundle all the files under a directory into a zip file. It is used by todolist-config to bundle all the configuration files (<strong>service-config.xml </strong>and <strong>remoting-config.xml</strong>) into a zip during the <strong>package </strong>phase.</li>
        <li><strong>maven-dependency-plugin</strong><strong> - </strong>can be used to unpack the zip file and move to the place you want. It is used by todolist-web to unpack the config zip during the <strong>generate-resources</strong> phase.</li>
    </ul>
    </li>
</ol>
<h2>Enhancements on maven POM</h2>
<p>I have modified the sample's maven pom as follows:</p>
<ul>
    <li>Link to new repository "<strong>Sonatype Forge</strong>" in the root POM. So, I can use the new version of flex-mojo and simplify the todolist-ria adobe framework dependencies. Apart from that, I also take away the private repository from Sebastein because BlazeDS libraries are available in official maven repository (Note: The BlazeDS libraries available in official maven repo are in version 3.0 instead of 3.0.0.544. So, you need to modify the webapp pom correspondingly).</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#60;repositories&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;repository&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;id&#62;flex-mojos-repository&#60;/id&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;url&#62;http://svn.sonatype.org/flexmojos/repository/&#60;/url&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;true&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;false&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/repository&#62;<br />
&#160;&#160;&#160; &#60;/repositories&#62;<br />
<br />
&#160;&#160;&#160; &#60;pluginRepositories&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;pluginRepository&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;id&#62;flex-mojos-repository&#60;/id&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;url&#62;http://svn.sonatype.org/flexmojos/repository/&#60;/url&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;true&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/releases&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;enabled&#62;false&#60;/enabled&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/snapshots&#62;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/pluginRepository&#62;<br />
&#160;&#160;&#160; &#60;/pluginRepositories&#62;</p>
</blockquote>
<ul>
    <li>Because I link to Sonatype repository, I can have my todolist-ria depends on one flex-framework pom dependency instead of all the swc dependencies. Note that the pom dependency is a way to factor out all the adobe swc dependencies that makes your pom easier to maintain.</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#160;&#160;&#160; &#60;dependency&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;groupId&#62;com.adobe.flex.framework&#60;/groupId&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;artifactId&#62;flex-framework&#60;/artifactId&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;version&#62;3.1.0.2710&#60;/version&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#60;type&#62;pom&#60;/type&#62;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#60;/dependency&#62;</p>
</blockquote>
<ul>
    <li>I include mysql driver as dependency in my webapp pom. I think it is cleaner to bundle it in war. I have also added <strong>jetty plugin</strong> in the POM so you have a web server embedded in the build process. With this, you can run this sample application right after you check it out from svn (assume you have maven 2 installed). To start jetty, you can issue the following maven command under your webapp project.</li>
</ul>
<blockquote>
<p>project_root&#62; mvn clean install<br />
project_root/jp-web&#62; mvn jetty:run-war</p>
</blockquote>
<ul>
    <li>I have included some reports that will be shown after site generation. You may not be able to do <strong>mvn site-deploy </strong>because it is linked to my web hosting site. However, you can modify it for your own sake.</li>
</ul>
<h2>Get the sample up on Eclipse</h2>
<p>To develop on Eclipse, you can follow the steps below:</p>
<ol>
    <li>Create Eclipse project file via running the command below at the project root. This will create 2 eclipse projects. One for todolist-ria and one for the webapp. You noticed that I use the <strong>-Declipse.downloadSource=true</strong> to include the source files of my dependencies in my eclipse project. Therefore, I can get to the source code if needed.</li>
</ol>
<blockquote>
<p>mvn -Declipse.downloadSource=true eclipse:eclipse</p>
</blockquote>
<ol>
    <li>Import the projects into Eclipse</li>
    <li>Add new variable<strong> M2_REPO</strong> and set it equals to<strong> [home]/.m2/repository</strong></li>
    <li>If you have installed <strong>Flex Builder plugin</strong> to your Eclipse, you can Add <strong>Flex Project Nature</strong> to the todolist-ria project.
    <ul>
        <li>Select Application Server Type: J2EE</li>
        <li>Put check on "Use remote object access service" with LiveCycle Data Service selected.</li>
        <li>Set up the path. I have my tomcat installed under C:\tools with default <strong>8080 </strong>as port. You should make the changes if you installed it differently.</li>
        <li><img src="http://www.solutionhacker.com/wp-content/uploads/image/flexEclipse1.JPG" style="width: 531px; height: 284px;" alt="" /></li>
        <li>Remove the generated <strong>main.mxml</strong> under the src folder.</li>
        <li>Set <strong>index.mxml </strong>under src folder as default Flex application file to run.</li>
        <li>Use <strong>Default Flex SDK </strong>in Flex Compiler Configuration instead of Server Flex SDK</li>
        <li>Right click and select <strong>Recreate HTML Template</strong> if you see error.</li>
        <li>After all these, you have configured your Flex application pointing to the webapp server and sharing the BlazeDS configuration files. You can verify in Flex Compiler Configuration's Additional Compiler Parameters. See whether you see this: <strong>-services "C:\tools\tomcat-6.0.16\webapps\jp\WEB-INF\flex\services-config.xml" -locale en_US</strong></li>
        <li>Move the war to your tomcat's webapp folder and start it under remote debugging setting. If you are using window, set<strong> DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n</strong> under your bin/catalina.bat.</li>
        <li>Start your webapp via bin/startup.bat</li>
        <li>Put breakpoint under <strong>TodoServiceImpl</strong> save method and start remote debugger on localhost:8787</li>
        <li>Right click the<strong> index.mxml</strong> and Run As Flex Application.</li>
        <li>Add a new entry and save it on the flex app. <img onclick="grin(':razz:');" alt=":razz:" src="../../../../../wp-includes/images/smilies/icon_razz.gif" /> You should see your remote debugger halt at the breakpoint for you to debug.</li>
        <li>Now you can change your flex code and test it out without leaving your Eclipse. However, if you modify the service in webapp, you need to run "<strong>mvn clean install</strong>" and deploy the war to the tomcat before your flex code can call your server-side code via <strong>AMF</strong>.</li>
    </ul>
    </li>
</ol>
<h2>Use Mate as Framework</h2>
<p>If you are not familiar with Mate, click the image below that moves you to a nice presentation.</p>
<p>&#160;<a href="http://mate.asfusion.com/assets/content//presentations/360_max_presentation.pdf"><img src="http://www.solutionhacker.com/wp-content/uploads/image/mate1.JPG" style="width: 589px; height: 339px;" alt="" /></a></p>
<p><u>What did I do to restructure the todolist sample to make it Mate app?</u></p>
<ol>
    <li>&#160;</li>
</ol>
<h2>Download</h2>
<p>I have made my work available at: <a href="http://www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip">www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip</a></p>
<h2>Reference</h2>
<p>Below are the references I used for the article:</p>
<ol>
    <li><a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">Flex mojo compiler user guide</a></li>
    <li><a href="http://blog.flex-mojos.info/2008/06/04/scopes/">Flex mojo dependency scope rules</a></li>
    <li><a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs">Flex 3 feature introduction: Flex 3 RSL</a></li>
    <li><a href="http://www.adobe.com/devnet/flex/articles/flash_player_cache.html">Improving Flex application performance using Flash Player Cache</a></li>
    <li><a href="http://fna.googlecode.com/svn/trunk/fna/site/mvn_archetypes/index.html">FNA archetype projects&#160;</a></li>
</ol>
<p>&#160;</p>]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>This article is written on top of the great work that&#160;<strong>Sébastien Arbogast </strong>has done. He has written 3 articles that showed you how to wire up Flex, BlazeDS, Spring, Hibernate and MySQL with Maven as build process. I have included his articles below as your reference.</p>
<ol>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt1.html">The Flex, Spring, and BlazeDS full stack – Part 1: Creating a Flex module</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt2.html">The Flex, Spring and BlazeDS full stack – Part 2: Writing the to-do list server</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/fullstack_pt3.html">The Flex, Spring and BlazeDS full stack – Part 3: Putting the application together</a></li>
</ol>
<p>I have found Sebastien&#8217;s work as a good foundation for my own project. To contribute back to the community, I will write a series of articles to show you how can customize and extend the todolist sample.</p>
<p><u>What is in the Part 1 of the series&#8230;</u></p>
<ol>
<li>Enhancements on the <strong>Maven </strong>build process
<ul>
<li>Leverage <strong>RSL </strong>to factor our the framework swc, so the size of the application swf will be reduced. Apart from that, I also take advantage of <strong>Flash Player Cache</strong> that is available after version 9 update 3 to cache the framework libraries.</li>
<li>Clean up the Flex and <strong>BlazeDS </strong>dependencies in POM as the latest version of the sdk is available and the BlazeDS dependencies are officially available.</li>
<li>Include some common reports for maven site generation</li>
<li>Embed <strong>Jetty</strong> web server in the build process for quick deployment and testing</li>
</ul>
</li>
<li>Document how to get the sample up on <strong>Eclipse </strong>for development<strong><br />
    </strong></li>
<li>Use <strong>Mate </strong>as Flex framework
<ul>
<li>Restructure ToDoList sample to leverage Mate framework</li>
<li>Factor out Mate as RSL and integrate it with Maven build process via Flex-mojo plugin.</li>
</ul>
</li>
</ol>
<p><u>What are in the coming articles&#8230;</u></p>
<ol>
<li>In part 2 of this series, I will show you how to use flex-mojo to build a modular Flex application.</li>
<li>In part 3 of this series, I will show you how to test your flex app via FlexUnit (Unit test) and FlexMonkey (Functional test)</li>
<li>In part 4 or this series, I will work on server side. I am planning to add monitoring, caching and security to the server side.</li>
</ol>
<p><span id="more-199"></span><!--more--></p>
<h2><!--more-->Review &#8220;ToDoList&#8221; sample</h2>
<p>Before I start my journey, let me highlight what Sebastien has done first:</p>
<ol>
<li>Sebastien&#8217;s sample demonstrates how to use Maven as a build process. There are 3 parts or subprojects in his sample. They are:
<ul>
<li><strong>todolist-config</strong> (configuration files shared by other subprojects)</li>
<li><strong>todolist-ria </strong>(Flex frontend)</li>
<li><strong>todolist-web</strong> (Server side that supports the Frontend)</li>
</ul>
</li>
<li>All these subprojects are considered as <strong>modules </strong>of the main project (root POM). Finally, they are combined together into war artifact and ready to deploy to Tomcat or other J2EE webapp server.</li>
<li>Flex frontend and backend communicate through a binary RPC protocol &#8211; <strong>AMF</strong>. AMF is considered to be the simplest and fastest remoting approach available in Flex. Recently, Adobe has released BlazeDS as an open source implementation of AMF spec. In this sample, <strong>BlazeDS </strong>is used. To use BlazeDS, there are few things you need to do:
<ul>
<li>Externalize your POJO service via BlazeDS. This sample shows you how to integrate BlazeDS with Spring</li>
<li>Make BlazeDS endpoints availabe to the Net via Servlet.</li>
<li>Have frontend and backend shared the same BlazeDS configuration files.</li>
</ul>
</li>
<li>In this sample, you can also find out how to use <strong>flex-mojo</strong> maven plugin to compile the Flex frontend code into swf. Apart from <a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">flex-mojo plugin</a>, there are other two good plugins worth to mention:
<ul>
<li><strong>maven-assembly-plugin </strong>- can be used to bundle all the files under a directory into a zip file. It is used by todolist-config to bundle all the configuration files (<strong>service-config.xml </strong>and <strong>remoting-config.xml</strong>) into a zip during the <strong>package </strong>phase.</li>
<li><strong>maven-dependency-plugin</strong><strong> &#8211; </strong>can be used to unpack the zip file and move to the place you want. It is used by todolist-web to unpack the config zip during the <strong>generate-resources</strong> phase.</li>
</ul>
</li>
</ol>
<h2>Enhancements on maven POM</h2>
<p>I have modified the sample&#8217;s maven pom as follows:</p>
<ul>
<li>Link to new repository &#8220;<strong>Sonatype Forge</strong>&#8221; in the root POM. So, I can use the new version of flex-mojo and simplify the todolist-ria adobe framework dependencies. Apart from that, I also take away the private repository from Sebastein because BlazeDS libraries are available in official maven repository (Note: The BlazeDS libraries available in official maven repo are in version 3.0 instead of 3.0.0.544. So, you need to modify the webapp pom correspondingly).</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &lt;repositories&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;repository&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;id&gt;flex-mojos-repository&lt;/id&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url&gt;http://svn.sonatype.org/flexmojos/repository/&lt;/url&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;true&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;false&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/repository&gt;<br />
&#160;&#160;&#160; &lt;/repositories&gt;</p>
<p>&#160;&#160;&#160; &lt;pluginRepositories&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;pluginRepository&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;id&gt;flex-mojos-repository&lt;/id&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;url&gt;http://svn.sonatype.org/flexmojos/repository/&lt;/url&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;true&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/releases&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;enabled&gt;false&lt;/enabled&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/snapshots&gt;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/pluginRepository&gt;<br />
&#160;&#160;&#160; &lt;/pluginRepositories&gt;</p>
</blockquote>
<ul>
<li>Because I link to Sonatype repository, I can have my todolist-ria depends on one flex-framework pom dependency instead of all the swc dependencies. Note that the pom dependency is a way to factor out all the adobe swc dependencies that makes your pom easier to maintain.</li>
</ul>
<blockquote>
<p>&#160;&#160;&#160; &#160;&#160;&#160; &lt;dependency&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;groupId&gt;com.adobe.flex.framework&lt;/groupId&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;artifactId&gt;flex-framework&lt;/artifactId&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;version&gt;3.1.0.2710&lt;/version&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &lt;type&gt;pom&lt;/type&gt;<br />
&#160;&#160;&#160; &#160;&#160;&#160; &lt;/dependency&gt;</p>
</blockquote>
<ul>
<li>I include mysql driver as dependency in my webapp pom. I think it is cleaner to bundle it in war. I have also added <strong>jetty plugin</strong> in the POM so you have a web server embedded in the build process. With this, you can run this sample application right after you check it out from svn (assume you have maven 2 installed). To start jetty, you can issue the following maven command under your webapp project.</li>
</ul>
<blockquote>
<p>project_root&gt; mvn clean install<br />
project_root/jp-web&gt; mvn jetty:run-war</p>
</blockquote>
<ul>
<li>I have included some reports that will be shown after site generation. You may not be able to do <strong>mvn site-deploy </strong>because it is linked to my web hosting site. However, you can modify it for your own sake.</li>
</ul>
<h2>Get the sample up on Eclipse</h2>
<p>To develop on Eclipse, you can follow the steps below:</p>
<ol>
<li>Create Eclipse project file via running the command below at the project root. This will create 2 eclipse projects. One for todolist-ria and one for the webapp. You noticed that I use the <strong>-Declipse.downloadSource=true</strong> to include the source files of my dependencies in my eclipse project. Therefore, I can get to the source code if needed.</li>
</ol>
<blockquote>
<p>mvn -Declipse.downloadSource=true eclipse:eclipse</p>
</blockquote>
<ol>
<li>Import the projects into Eclipse</li>
<li>Add new variable<strong> M2_REPO</strong> and set it equals to<strong> [home]/.m2/repository</strong></li>
<li>If you have installed <strong>Flex Builder plugin</strong> to your Eclipse, you can Add <strong>Flex Project Nature</strong> to the todolist-ria project.
<ul>
<li>Select Application Server Type: J2EE</li>
<li>Put check on &#8220;Use remote object access service&#8221; with LiveCycle Data Service selected.</li>
<li>Set up the path. I have my tomcat installed under C:\tools with default <strong>8080 </strong>as port. You should make the changes if you installed it differently.</li>
<li><img src="http://www.solutionhacker.com/wp-content/uploads/image/flexEclipse1.JPG" style="width: 531px; height: 284px;" alt="" /></li>
<li>Remove the generated <strong>main.mxml</strong> under the src folder.</li>
<li>Set <strong>index.mxml </strong>under src folder as default Flex application file to run.</li>
<li>Use <strong>Default Flex SDK </strong>in Flex Compiler Configuration instead of Server Flex SDK</li>
<li>Right click and select <strong>Recreate HTML Template</strong> if you see error.</li>
<li>After all these, you have configured your Flex application pointing to the webapp server and sharing the BlazeDS configuration files. You can verify in Flex Compiler Configuration&#8217;s Additional Compiler Parameters. See whether you see this: <strong>-services &#8220;C:\tools\tomcat-6.0.16\webapps\jp\WEB-INF\flex\services-config.xml&#8221; -locale en_US</strong></li>
<li>Move the war to your tomcat&#8217;s webapp folder and start it under remote debugging setting. If you are using window, set<strong> DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n</strong> under your bin/catalina.bat.</li>
<li>Start your webapp via bin/startup.bat</li>
<li>Put breakpoint under <strong>TodoServiceImpl</strong> save method and start remote debugger on localhost:8787</li>
<li>Right click the<strong> index.mxml</strong> and Run As Flex Application.</li>
<li>Add a new entry and save it on the flex app. <img onclick="grin(':razz:');" alt=":razz:" src="../../../../../wp-includes/images/smilies/icon_razz.gif" /> You should see your remote debugger halt at the breakpoint for you to debug.</li>
<li>Now you can change your flex code and test it out without leaving your Eclipse. However, if you modify the service in webapp, you need to run &#8220;<strong>mvn clean install</strong>&#8221; and deploy the war to the tomcat before your flex code can call your server-side code via <strong>AMF</strong>.</li>
</ul>
</li>
</ol>
<h2>Use Mate as Framework</h2>
<p>If you are not familiar with Mate, click the image below that moves you to a nice presentation.</p>
<p>&#160;<a href="http://mate.asfusion.com/assets/content//presentations/360_max_presentation.pdf"><img src="http://www.solutionhacker.com/wp-content/uploads/image/mate1.JPG" style="width: 589px; height: 339px;" alt="" /></a></p>
<p><u>What did I do to restructure the todolist sample to make it Mate app?</u></p>
<ol>
<li>&#160;</li>
</ol>
<h2>Download</h2>
<p>I have made my work available at: <a href="http://www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip">www.solutionhacker.com/wp-content/uploads/todolist-jp-modified.zip</a></p>
<h2>Reference</h2>
<p>Below are the references I used for the article:</p>
<ol>
<li><a href="http://docs.flex-mojos.info/flex-compiler-mojo/compile-swf-mojo.html">Flex mojo compiler user guide</a></li>
<li><a href="http://blog.flex-mojos.info/2008/06/04/scopes/">Flex mojo dependency scope rules</a></li>
<li><a href="http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:Flex_3_RSLs">Flex 3 feature introduction: Flex 3 RSL</a></li>
<li><a href="http://www.adobe.com/devnet/flex/articles/flash_player_cache.html">Improving Flex application performance using Flash Player Cache</a></li>
<li><a href="http://fna.googlecode.com/svn/trunk/fna/site/mvn_archetypes/index.html">FNA archetype projects&#160;</a></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/uncategorized/wiring-up-flex-mate-blazeds-spring-hibernate-and-mysql-with-maven-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

