<?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>Dario Quintana &#187; Aop</title>
	<atom:link href="http://darioquintana.com.ar/blogging/category/aop/feed/" rel="self" type="application/rss+xml" />
	<link>http://darioquintana.com.ar/blogging</link>
	<description>at blogging</description>
	<lastBuildDate>Mon, 18 Apr 2011 04:31:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>3 layer Example of NHibernate + Spring.Net + AOP</title>
		<link>http://darioquintana.com.ar/blogging/2007/11/17/3-layer-example-of-nhibernate-springnet-aop/</link>
		<comments>http://darioquintana.com.ar/blogging/2007/11/17/3-layer-example-of-nhibernate-springnet-aop/#comments</comments>
		<pubDate>Sat, 17 Nov 2007 14:15:28 +0000</pubDate>
		<dc:creator>Dario</dc:creator>
				<category><![CDATA[Aop]]></category>
		<category><![CDATA[IoC]]></category>
		<category><![CDATA[NHibernate]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[uNHAddIns]]></category>

		<guid isPermaLink="false">http://darioquintana.com.ar/blogging/?p=19</guid>
		<description><![CDATA[<a href="http://darioquintana.com.ar/blogging/2007/11/17/3-layer-example-of-nhibernate-springnet-aop/" title="3 layer Example of NHibernate + Spring.Net + AOP"></a>Sometime ago I wrote this template project using Spring.Net and NHibernateprimarily. I use NHibernate for the data access and Spring.Netfor the IoC and Aop. With the Aop support, the transaction managmente it&#8217;s very easy to implement. This it&#8217;s the CustomerService &#8230;<p class="read-more"><a href="http://darioquintana.com.ar/blogging/2007/11/17/3-layer-example-of-nhibernate-springnet-aop/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://darioquintana.com.ar/blogging/2007/11/17/3-layer-example-of-nhibernate-springnet-aop/" title="3 layer Example of NHibernate + Spring.Net + AOP"></a><p>Sometime ago I wrote this template project using <a href="http://springframework.net/">Spring.Net</a> and <a href="http://www.hibernate.org/343.html">NHibernate</a>primarily. I use <a href="http://www.hibernate.org/343.html">NHibernate</a> for the data access and <a href="http://springframework.net/">Spring.Net</a>for the IoC and Aop. With the Aop support, the transaction managmente it&#8217;s very easy to implement.</p>
<p>This it&#8217;s the <em>CustomerService</em> class:</p>
<pre class="csharpcode">
    <span class="kwrd">public</span> <span class="kwrd">class</span> CustomerService : BaseService, ICustomerService
    {
	<span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// This field is inyected by IoC through the property.</span>
        <span class="rem">/// &lt;/summary&gt;</span>

        <span class="kwrd">private</span> ICustomerDao customerDao;        <span class="kwrd"></span>
 <span class="kwrd">	public</span> ICustomerDao CustomerDao {
            get { <span class="kwrd">return</span> customerDao; }
          set { customerDao = <span class="kwrd">value</span>; }
        }

<span class="preproc">#region</span> ICustomerService Members

<span class="kwrd">	public</span> <span class="kwrd">int</span> CreateCustomer(<span class="kwrd">string</span> Name, <span class="kwrd">string</span> LastName) {

        	Customer customer = <span class="kwrd">new</span> Customer();

        	customer.FirstName = <span class="str">"Dario"</span>;

	        customer.LastName = <span class="str">"Quintana"</span>;

		CustomerDao.Save(customer);

<span class="kwrd">		return</span> customer.Id;

        }

<span class="kwrd">	public</span> <span class="kwrd">void</span> DeleteCustomer(<span class="kwrd">int</span> Id) {

            	Customer customer = CustomerDao.GetById(Id);

		CustomerDao.Delete(customer);

        }

<span class="preproc">#endregion</span>

    }</pre>
<p>As you can see, the <em>CreateCustomer</em> or <em>DeleteCustomer</em> is not envolved at code by anyone Transactional or UnitOfWork code, nor the method <em>Save(customer)</em> at <em>CustomerDao</em> class.</p>
<p>Then&#8230; where it&#8217;s the transactional support ? Spring + AOP is the answer. Spring envolves al Service methods between transaccions.</p>
<p>When you instantiate the class CustomerService, a proxy is instantiate insted. With the proxy Spring.Net can envolve the method configurated into transactions. Cool uh?</p>
<p>Another thing that you can appreciate at example it&#8217;s the using of <a href="http://code.google.com/p/unhaddins/">uNhAddIns</a> at Repository stuff. With this library you can use Hql/Sql queries detached with the class <a href="http://darioquintana.com.ar/blogging/?p=5">DetachedQuery</a>. With DetachedQuery you can use <a href="http://darioquintana.com.ar/blogging/?p=7">NamedQuery and this a good practice to adopt</a>.</p>
<h4><a href="http://code.google.com/p/darioquintana/downloads/detail?name=SpringNHAop.7z">Download the Example</a></h4>
]]></content:encoded>
			<wfw:commentRss>http://darioquintana.com.ar/blogging/2007/11/17/3-layer-example-of-nhibernate-springnet-aop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

