<?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>Tadaya's Weblog</title>
	<atom:link href="http://tadaya.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tadaya.wordpress.com</link>
	<description>Software development must be fun.</description>
	<lastBuildDate>Mon, 23 Jan 2012 16:51:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tadaya.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tadaya's Weblog</title>
		<link>http://tadaya.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tadaya.wordpress.com/osd.xml" title="Tadaya&#039;s Weblog" />
	<atom:link rel='hub' href='http://tadaya.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Use jobParameters value in HibernateCursorItemReader HQL</title>
		<link>http://tadaya.wordpress.com/2010/10/08/use-jobparameters-value-in-hibernatecursoritemreader-hql/</link>
		<comments>http://tadaya.wordpress.com/2010/10/08/use-jobparameters-value-in-hibernatecursoritemreader-hql/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 00:03:25 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring-batch]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=25</guid>
		<description><![CDATA[When ItemReader, ItemWriter, or ItemProcessor need to use JobParameters, you can set their bean scope to &#8220;step&#8221; and able to reference parameters. doesn&#8217;t need to use spring3 bean needs to be a &#8220;step&#8221; scope. expressions are  &#8221;#{}&#8221; or &#8220;%{}&#8221;. impl is : org.springframework.batch.core.scope.StepScope.ExpressionHider Here, I pass &#8220;from_date&#8221; as jobParameter, and bind it to the item reader [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=25&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When <em>ItemReader</em>, <em>ItemWriter</em>, or <em>ItemProcessor</em> need to use JobParameters, you can set their bean scope to &#8220;step&#8221; and able to reference parameters.</p>
<ul>
<li>doesn&#8217;t need to use spring3</li>
<li>bean needs to be a &#8220;step&#8221; scope.</li>
<li>expressions are  &#8221;#{}&#8221; or &#8220;%{}&#8221;.<br />
impl is : <em>org.springframework.batch.core.scope.StepScope.ExpressionHider</em></li>
</ul>
<p>Here, I pass &#8220;from_date&#8221; as jobParameter, and bind it to the item reader HQL of <em>HibernateCursorItemReader</em>.</p>
<p><pre class="brush: xml;">
  &lt;bean id=&quot;hibernateReader&quot;
         class=&quot;org.springframework.batch.item.database.HibernateCursorItemReader&quot;
         scope=&quot;step&quot;&gt;
    &lt;property name=&quot;sessionFactory&quot; ref=&quot;sessionFactory&quot;/&gt;
    &lt;property name=&quot;queryString&quot;&gt;
       &lt;value&gt;
          &lt;![CDATA[ from Something where start_date &lt;= :reqFromDate ]]&gt;
       &lt;/value&gt;
    &lt;/property&gt;
    &lt;property name=&quot;parameterValues&quot;&gt;
      &lt;map&gt;
        &lt;entry key=&quot;reqFromDate&quot; value=&quot;#{jobParameters['from_date']}&quot;/&gt;
      &lt;/map&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=25&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2010/10/08/use-jobparameters-value-in-hibernatecursoritemreader-hql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>
	</item>
		<item>
		<title>OpenSessionInViewFilter v.s. OpenSessionInViewInterceptor</title>
		<link>http://tadaya.wordpress.com/2008/07/31/opensessioninview-filter-vs-interceptor/</link>
		<comments>http://tadaya.wordpress.com/2008/07/31/opensessioninview-filter-vs-interceptor/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 14:24:07 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=14</guid>
		<description><![CDATA[Spring provides two implementation to achieve open session in view pattern. - OpenSessionInViewFilter - OpenSessionInViewInterceptor Both of them will keep hibernate session open until view is rendered. However, even though both provides same function, they are implemented on fundamentally different techniques. Interceptor: use Spring MVC function small granularity to apply configure in applicationContext.xml, [servlet_name]-servlet.xml, or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=14&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Spring provides two implementation to achieve open session in view pattern.</p>
<p>- <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.html" target="_blank">OpenSessionInViewFilter<br />
</a>- <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/support/OpenSessionInViewInterceptor.html" target="_blank">OpenSessionInViewInterceptor</a></p>
<p>Both of them will keep hibernate session open until view is rendered. However, even though both provides same function, they are implemented on fundamentally different techniques.</p>
<h2>Interceptor:</h2>
<ul>
<li>use Spring MVC function</li>
<li>small granularity to apply</li>
<li>configure in applicationContext.xml, [servlet_name]-servlet.xml, or spring config file.</li>
</ul>
<p style="padding-left:30px;">* use DispatcherServlet (Spring MVC) interceptor function to keep opening hibernate session.</p>
<p style="padding-left:30px;">* If you only need to open hibernate session for specific controllers, interceptor is a best choice because it can be configured to each controller(actually, handler mapping level).</p>
<p style="padding-left:60px;">e.g.) one controller uses hibernate, but another controller uses different technology.</p>
<p style="padding-left:60px;">
<p style="padding-left:60px;"><a href="http://tadaya.files.wordpress.com/2008/07/opensessioninview-interceptor.png"><img class="alignnone size-medium wp-image-15" src="http://tadaya.files.wordpress.com/2008/07/opensessioninview-interceptor.png?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<h2>Filter:</h2>
<ul>
<li>use ServletFilter function</li>
<li>large granularity to apply</li>
<li>configure in web.xml</li>
<li>Spring MVC is not required.</li>
</ul>
<p style="padding-left:30px;">* servlet specification</p>
<p style="padding-left:30px;"><a href="http://tadaya.files.wordpress.com/2008/07/opensessioninview-filter.png"><img class="alignnone size-medium wp-image-16" src="http://tadaya.files.wordpress.com/2008/07/opensessioninview-filter.png?w=300&#038;h=225" alt="" width="300" height="225" /></a></p>
<p style="padding-left:30px;">
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=14&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/07/31/opensessioninview-filter-vs-interceptor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>

		<media:content url="http://tadaya.files.wordpress.com/2008/07/opensessioninview-interceptor.png?w=300" medium="image" />

		<media:content url="http://tadaya.files.wordpress.com/2008/07/opensessioninview-filter.png?w=300" medium="image" />
	</item>
		<item>
		<title>Expose Java5 Enum to JSP(JSTL)</title>
		<link>http://tadaya.wordpress.com/2008/07/28/expose-java5-enum-to-jsp-jstl/</link>
		<comments>http://tadaya.wordpress.com/2008/07/28/expose-java5-enum-to-jsp-jstl/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 03:46:52 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=9</guid>
		<description><![CDATA[Currently, Enum cannot be directly referenced in JSTL We cannot do these: ${ my.package.Enum } ${ someEnum == MyEnum } So, in order to access enums easily, Enums need to be in HttpServletRequest (request scope) or ServletContext(application scope). Store in ServletContext (Application scope) Store in HttpServletRequest (request scope, request.setAttribute()) ServletFilter (servlet) HandlerInterceptor (spring) Controller (spring, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=9&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Currently, Enum cannot be directly referenced in JSTL</p>
<p>We cannot do these:</p>
<ul>
<li>${ my.package.Enum }</li>
<li>${ someEnum == MyEnum }</li>
</ul>
<p>So, in order to access enums easily, Enums need to be in HttpServletRequest (request scope) or ServletContext(application scope).</p>
<ol>
<li>Store in ServletContext (Application scope)</li>
<li>Store in HttpServletRequest (request scope, request.setAttribute())
<ul>
<li>ServletFilter (servlet)</li>
<li>HandlerInterceptor (spring)</li>
<li>Controller (spring, web-layer-action)</li>
</ul>
</li>
</ol>
<h3>Sample Enum Class</h3>
<p><pre class="brush: java;">
public enum Language {
    EN(&quot;English&quot;),
    JP(&quot;Japanese&quot;);

    private String name;

    Language(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
}
</pre></p>
<h3>HandlerInterceptor</h3>
<p><pre class="brush: java;">
public class EnumExposureHandlerInterceptor extends HandlerInterceptorAdapter {

    private Set&lt;Class&lt;? extends Enum&gt;&gt; enumClasses = new HashSet&lt;Class&lt;? extends Enum&gt;&gt;();

    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {

        for (Class&lt;? extends Enum&gt; enumClass : enumClasses) {
            final String enumClassName = enumClass.getSimpleName();  // class of enum : Language
            final Enum[] enums = enumClass.getEnumConstants();  // enum instances : EN, JP,...

            // put them into map, so that we can access like this : Language.EN, Language.JP ...
            Map&lt;String, Enum&gt; map = new HashMap&lt;String, Enum&gt;(enums.length);
            for (Enum anEnum : enums) {
                map.put(anEnum.name(), anEnum);
            }

            // seting to scope
            request.setAttribute(enumClassName, map);
        }

    }

    public void setEnumClasses(Set&lt;Class&lt;? extends Enum&gt;&gt; enumClasses) {
        this.enumClasses = enumClasses;
    }
}
</pre></p>
<h4>Spring Configuration</h4>
<p><pre class="brush: xml;">
&lt;bean class=&quot;org.springframework.web.servlet.handler.SimpleUrlHandlerMapping&quot;&gt;
&lt;property name=&quot;urlMap&quot; ref=&quot;urlMap&quot;/&gt;
&lt;property name=&quot;interceptors&quot;&gt;
	&lt;list&gt;
            &lt;bean class=&quot;mypackage.EnumExposureHandlerInterceptor&quot;&gt;
&lt;property name=&quot;enumClasses&quot;&gt;
                    &lt;set&gt;
                        &lt;value&gt;mypackage.Language&lt;/value&gt;
                    &lt;/set&gt;
                &lt;/property&gt;
             &lt;/bean&gt;
         &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=9&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/07/28/expose-java5-enum-to-jsp-jstl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>
	</item>
		<item>
		<title>JdbcTemplate details part3</title>
		<link>http://tadaya.wordpress.com/2008/05/12/jdbctemplate-details-part3/</link>
		<comments>http://tadaya.wordpress.com/2008/05/12/jdbctemplate-details-part3/#comments</comments>
		<pubDate>Tue, 13 May 2008 02:52:57 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=8</guid>
		<description><![CDATA[Error translation Translate java.sql.SqlException to Spring&#8217;s data access exception hierarchy. DataAccessException Root cause for all dao access exceptions. unchecked exception. direct parent class is NestedRuntimeException Native jdbc resource When you need to work on native jdbc connections instead of spring wrapped connections, providing NativeJdbcExtractor to jdbcTemplate allows you to retrieve native connections. Then, you can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=8&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Error translation</h2>
<p>Translate java.sql.SqlException to Spring&#8217;s data access exception hierarchy.</p>
<p style="padding-left:30px;"><strong><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/dao/DataAccessException.html" target="_blank"> DataAccessException<br />
</a></em></strong> Root cause for all dao access exceptions. unchecked exception.<br />
direct parent class is NestedRuntimeException</p>
<h2>Native jdbc resource</h2>
<p>When you need to work on native jdbc connections instead of spring wrapped connections, providing <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/support/nativejdbc/NativeJdbcExtractor.html" target="_blank">NativeJdbcExtractor</a> to jdbcTemplate allows you to retrieve native connections. Then, you can cast the connection to the vendor specific connection object.</p>
<h2>SingleConnectionDataSource, DriverManagerDataSource</h2>
<p>Datasource for testing.</p>
<p style="padding-left:30px;"><strong><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/DriverManagerDataSource.html" target="_blank">DriverManagerDataSource</a></em></strong><br />
Create new connection every time.<br />
useful for test outside of container, based on what API says.</p>
<p style="padding-left:30px;"><strong><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/SingleConnectionDataSource.html" target="_blank">SingleConnectionDataSource</a></em></strong><br />
Sub class of DriverManagerDataSource.<br />
Always use the same connection, and not for multi threaded environement.</p>
<h2>Transaction Management in JDBC</h2>
<p style="padding-left:30px;"><strong><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/DataSourceUtils.html" target="_blank">DatasourceUtils</a></em></strong><br />
Utility class to retrieve a connection from spring transaction managers(thread bounded connection).</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.html" target="_blank"><strong><em>TransactionAwareDataSourceProxy</em></strong></a><br />
Let your datasource participate spring transaction management. reference my other <a href="http://tadaya.wordpress.com/2008/04/27/transaction-aware-datasource-use-dbunit-hibernate-in-spring/" target="_blank">post</a>.</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/DataSourceTransactionManager.html" target="_blank"><strong><em>DataSourceTransactionManager</em></strong></a><br />
Implementation of PlatformTransactionManager. So, use this as a transaction manager if application solely use datasource. Bind connection to current thread.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=8&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/05/12/jdbctemplate-details-part3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>
	</item>
		<item>
		<title>JdbcTemplate details part2</title>
		<link>http://tadaya.wordpress.com/2008/05/09/jdbctemplate-details-part2/</link>
		<comments>http://tadaya.wordpress.com/2008/05/09/jdbctemplate-details-part2/#comments</comments>
		<pubDate>Fri, 09 May 2008 14:46:12 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=7</guid>
		<description><![CDATA[Package Hierarchy org.springframework.jdbc.core contains JdbcTemplate org.springframework.jdbc.core.simple SimpleJdbcTemplate related classes org.springframework.jdbc.core.namedparam NamedParameterJdbcTemplate related classes org.springframework.jdbc.datasource datasource for spring managed environment related classes org.springframework.jdbc.datasource.lookup datasource lookup org.springframework.jdbc.object treat sqls and stored procedure as objects org.springframework.jdbc.support Error translation related classes Batch update JdbcTemplate#batchUpdate() implement BatchPreparedStatementSetter or InterruptibleBatchPreparedStatement interfaces For SimpleJdbcTemplate you can also use value maps, bean property [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=7&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Package Hierarchy</h2>
<ul>
<li><span class="FrameItemFont"><a id="w2we2" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/package-frame.html" target="packageFrame">org.springframework.jdbc.core</a></span>
<ul>
<li>contains JdbcTemplate</li>
</ul>
</li>
<li><span class="FrameItemFont"><a id="r-s-2" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/simple/package-frame.html" target="packageFrame">org.springframework.jdbc.core.simple</a></span>
<ul>
<li>SimpleJdbcTemplate related classes</li>
</ul>
</li>
<li><span class="FrameItemFont"><a id="g39w2" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/namedparam/package-frame.html" target="packageFrame">org.springframework.jdbc.core.namedparam</a></span>
<ul>
<li>NamedParameterJdbcTemplate related classes</li>
</ul>
</li>
<li><span class="FrameItemFont"><a id="lar34" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/lookup/package-frame.html" target="packageFrame">org.springframework.jdbc.datasource</a></span>
<ul>
<li><span class="FrameItemFont">datasource for spring managed environment related classes</span></li>
</ul>
</li>
<li><span class="FrameItemFont"><a id="lar34" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/lookup/package-frame.html" target="packageFrame">org.springframework.jdbc.datasource.lookup</a></span>
<ul>
<li><span class="FrameItemFont">datasource lookup</span></li>
</ul>
</li>
<li><span class="FrameItemFont"><a id="vi3" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/object/package-frame.html" target="packageFrame">org.springframework.jdbc.object</a></span>
<ul>
<li>treat sqls and stored procedure as objects</li>
</ul>
</li>
<li><span class="FrameItemFont"><a id="jphp3" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/support/package-frame.html" target="packageFrame">org.springframework.jdbc.support</a></span>
<ul>
<li>Error translation related classes</li>
</ul>
</li>
</ul>
<h2>Batch update</h2>
<p style="padding-left:30px;"><strong><em>JdbcTemplate#batchUpdate()</em></strong><br />
implement <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/BatchPreparedStatementSetter.html" target="_blank">BatchPreparedStatementSetter</a> or <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/InterruptibleBatchPreparedStatementSetter.html" target="_blank">InterruptibleBatchPreparedStatement</a> interfaces</p>
<p style="padding-left:30px;"><strong><em>For SimpleJdbcTemplate</em></strong><br />
you can also use value maps, bean property based objects, or <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/namedparam/SqlParameterSource.html" target="_blank">SqlParameterSources</a><br />
see <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/namedparam/SqlParameterSourceUtils.html" target="_blank">SqlParameterSourceUtils</a></p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/object/BatchSqlUpdate.html" target="_blank"><strong><em>BatchSqlUpdate</em></strong></a><br />
represente batch update sql as a java class.</p>
<h2>SimpleJdbc classes</h2>
<p>simplified jdbc operation classes using database metadata(retrieved from JDBC driver).</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.html" target="_blank"><strong><em>SimpleJdbcTemplate</em></strong></a><br />
enhanced jdbcTemplate with java5 functions.</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/simple/SimpleJdbcInsert.html" target="_blank"><strong><em>SimpleJdbcInsert</em></strong></a><br />
by giving table name(withTableName()), column names, and values, you can execute insert operation.</p>
<p style="padding-left:30px;"><strong><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/simple/SimpleJdbcCall.html" target="_blank">SimpleJdbcCall</a></em></strong><br />
simple execution for stored procedure. in/out parameters can be given as Map, or SqlParmaeterSource.</p>
<h2>JDBC Operations</h2>
<p>considering each DB operation as object</p>
<p style="padding-left:30px;"><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/object/SqlQuery.html" target="_blank"><strong>SqlQuery</strong></a></em><br />
abstract class that encapsulate all sql operations. This class defines a lot of execution methods. When you implement this class, need to provide rowMapper.</p>
<p style="padding-left:30px;"><strong><em><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/object/SqlUpdate.html" target="_blank">SqlUpdate</a></em></strong><br />
represent update operation as an object.<br />
StoredProcedure: abstract class that you can extend for your stored procedure.</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/object/SqlFunction.html" target="_blank"><strong><em>SqlFunction</em></strong></a><br />
expect single result</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=7&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/05/09/jdbctemplate-details-part2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>
	</item>
		<item>
		<title>JdbcTemplate details part1</title>
		<link>http://tadaya.wordpress.com/2008/05/05/jdbctemplate-details-part1/</link>
		<comments>http://tadaya.wordpress.com/2008/05/05/jdbctemplate-details-part1/#comments</comments>
		<pubDate>Tue, 06 May 2008 02:41:04 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=6</guid>
		<description><![CDATA[JdbcTemplate methods Data Retrieval queryForInt(), queryForLong() expects unique value. queryForMap() expects one row. each column is a map key. queryForList() expects multiple rows. each entry of list is a map, and the map uses columns as keys. queryForObject() expects one row as an instance query() expects multiple rows. returns multiple objects. each row becomes one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=6&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>JdbcTemplate methods</h2>
<h3><strong>Data Retrieval</strong></h3>
<p style="padding-left:30px;"><strong><em>queryForInt(), queryForLong()</em></strong><br />
expects unique value.</p>
<p style="padding-left:30px;"><em><strong>queryForMap()</strong></em><br />
expects one row. each column is a map key.</p>
<p style="padding-left:30px;"><strong><em>queryForList()</em></strong><br />
expects multiple rows. each entry of list is a map, and the map uses columns as keys.</p>
<p style="padding-left:30px;"><strong><em>queryForObject()</em></strong><br />
expects one row as an instance</p>
<p style="padding-left:30px;"><strong><em>query()</em></strong><br />
expects multiple rows. returns multiple objects. each row becomes one instance.</p>
<p style="padding-left:30px;">
<h4 style="padding-left:30px;"><strong>classes</strong></h4>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/PreparedStatementCreator.html" target="_blank"><strong>* PreparedStatementCreator</strong></a><br />
create prepared statement and bind values</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/PreparedStatementSetter.html" target="_blank"><strong>* PreparedStatementSetter</strong></a><br />
bind values to prepared statement when you want to separate creation of prepared statement binding of values.</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/ResultSetExtractor.html" target="_blank"><strong>* ResultSetExtractor</strong></a><br />
process entire resultset and return one object. recommended to access resultset  stateless</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/RowCallbackHandler.html" target="_blank"><strong>* RowCallbackHandler</strong></a><br />
process entire resultset statefull. Object which implement this interface will usually used after jdbctemplate call.</p>
<p style="padding-left:30px;"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/RowMapper.html" target="_blank"><strong>* RowMapper</strong></a><br />
process each result row and construct an object.</p>
<h3><strong>Data Manipulation</strong></h3>
<p style="padding-left:30px;"><em><strong>update()</strong></em><br />
for insert,update, and delete statement</p>
<h3><strong>etc.</strong></h3>
<p style="padding-left:30px;"><strong><em>execute()</em></strong><br />
for DDL</p>
<h2>JdbcTemplate extensions</h2>
<p style="padding-left:30px;"><strong><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.html" target="_blank">* NamedParameterJdbcTemplate</a></strong><br />
Support named parameter (&#8216;:id&#8217;,':name&#8217;), use SqlParameterSource or Map to bind values to named parameters.</p>
<p style="padding-left:30px;"><strong><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/namedparam/SqlParameterSource.html" target="_blank">* SqlParameterSource</a></strong><br />
interface that represents keys, values, and sqlTypes for named parameters.</p>
<p style="padding-left:30px;"><strong><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/core/simple/SimpleJdbcTemplate.html" target="_blank">* SimpleJdbcTemplate</a></strong><br />
use Java5 functions such as vargs and generic.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=6&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/05/05/jdbctemplate-details-part1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>
	</item>
		<item>
		<title>Transaction aware datasource (use dbunit &amp; hibernate in spring)</title>
		<link>http://tadaya.wordpress.com/2008/04/27/transaction-aware-datasource-use-dbunit-hibernate-in-spring/</link>
		<comments>http://tadaya.wordpress.com/2008/04/27/transaction-aware-datasource-use-dbunit-hibernate-in-spring/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 00:03:54 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[unittest]]></category>

		<guid isPermaLink="false">http://tadaya.wordpress.com/?p=3</guid>
		<description><![CDATA[[UseCase] use dbunit &#38; hibernate in unit test prepare test data with dbunit using datasource test a dao method with hibernate rollback all data (each testcase doesn&#8217;t pollute data) [Issue] preparing test data and running a test method must be executed under the same transaction in order to rollback. =&#62; dbunit(datasource) needs to participate spring [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=3&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>[UseCase]</strong></p>
<p>use dbunit &amp; hibernate in unit test</p>
<ul>
<li> prepare test data with <span style="color:#800000;">dbunit</span> using datasource</li>
<li> test a dao method with <span style="color:#800000;">hibernate</span></li>
<li> rollback all data (each testcase doesn&#8217;t pollute data)</li>
</ul>
<p><strong>[Issue]</strong></p>
<p>preparing test data and running a test method must be executed under the same transaction in order to rollback.<br />
=&gt; <em>dbunit(datasource) needs to participate spring transaction management. </em></p>
<p><strong>[Solution]</strong></p>
<p>use <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.html" target="_blank">TransactionAwareDatasourceProxy</a></p>
<p><strong>[How it works]</strong><a href="http://tadaya.files.wordpress.com/2008/04/datasource1.png"><img class="alignnone size-full wp-image-4" src="http://tadaya.files.wordpress.com/2008/04/datasource1.png?w=550&#038;h=412" alt="" width="550" height="412" /></a></p>
<p><a href="http://tadaya.files.wordpress.com/2008/04/datasource2.png"><img class="alignnone size-full wp-image-5" src="http://tadaya.files.wordpress.com/2008/04/datasource2.png?w=550&#038;h=412" alt="" width="550" height="412" /></a></p>
<p>Transaction manager acquires a DB connection and put it to connection holder in thread local.<br />
Whenever getConnection() is called, same connection will be retrieved from connection holder.<br />
When close() is called, it doesn&#8217;t close connection.<br />
At the end of transaction, finally connection will be closed.</p>
<p><strong><em>ConnectionHolder</em></strong><br />
When transaction manager begins transaction, ConnectionHolder instance will be created and hold actual connection.<br />
When transaction is done, connection will be closed.</p>
<p><strong><em>TransactionAwareDataSourceProxy</em></strong><br />
wrap original datasource.<br />
implementing DataSource interface<br />
participate spring managed transaction control</p>
<p><strong><em>TransactionAwareInvocationHandler</em></strong><br />
proxy of Connection class<br />
private inner class<br />
delegate standard Connection methods(equals, close, &#8230;) to DataSourceUtils</p>
<p><strong>[Sample Config]</strong></p>
<p><pre class="brush: xml;">
&lt;!--
 | Datasource with Transaction support.
--&gt;

&lt;bean id=&quot;dataSource&quot; class=&quot;org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy&quot;&gt;
     &lt;constructor-arg ref=&quot;dbcpDataSource&quot;/&gt;
&lt;/bean&gt;

&lt;bean id=&quot;dbcpDataSource&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot; destroy-method=&quot;close&quot;&gt;
     &lt;property name=&quot;driverClassName&quot; value=&quot;${hibernate.connection.driver_class}&quot;/&gt;
     &lt;property name=&quot;url&quot; value=&quot;${hibernate.connection.url}&quot;/&gt;
     &lt;property name=&quot;username&quot; value=&quot;${hibernate.connection.username}&quot;/&gt;
     &lt;property name=&quot;password&quot; value=&quot;${hibernate.connection.password}&quot;/&gt;
&lt;/bean&gt;

&lt;bean id=&quot;sessionFactory&quot; class=&quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot;&gt;
    &lt;property name=&quot;dataSource&quot; ref=&quot;dataSource&quot;/&gt;
    &lt;property name=&quot;configLocation&quot; value=&quot;classpath:hibernate.cfg.xml&quot;/&gt;
    &lt;property name=&quot;configurationClass&quot; value=&quot;org.hibernate.cfg.AnnotationConfiguration&quot;/&gt;
    &lt;property name=&quot;hibernateProperties&quot; ref=&quot;hibernateProperties&quot;/&gt;
    &lt;!--&lt;property name=&quot;useTransactionAwareDataSource&quot; value=&quot;true&quot;/&gt;--&gt;
&lt;/bean&gt;
</pre></p>
<p><strong>[Sample Test Code]</strong></p>
<p><pre class="brush: java;">
final IDatabaseConnection dbUnitConnection = new DatabaseConnection(this.getDataSource());

// Do some operations with dbunit
// eg)
// DatabaseOperation.DELETE.execute(connection, dataSet);

// this doesn't close connection since method is executed under transaction
DataSourceUtils.releaseConnection(dbUnitConnection.getConnection(), this.getDataSource());
</pre></p>
<p><strong>[Key Spring Classes]</strong></p>
<ul>
<li><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.html" target="_blank">org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy</a></li>
<li><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jdbc/datasource/DataSourceUtils.html" target="_blank">org.springframework.jdbc.datasource.DataSourceUtils</a></li>
<li><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.html" target="_blank">org.springframework.test.AbstractTransactionalDataSourceSpringContextTests</a></li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=3&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/04/27/transaction-aware-datasource-use-dbunit-hibernate-in-spring/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>

		<media:content url="http://tadaya.files.wordpress.com/2008/04/datasource1.png" medium="image" />

		<media:content url="http://tadaya.files.wordpress.com/2008/04/datasource2.png" medium="image" />
	</item>
		<item>
		<title>Hello world!</title>
		<link>http://tadaya.wordpress.com/2008/03/02/hello-world/</link>
		<comments>http://tadaya.wordpress.com/2008/03/02/hello-world/#comments</comments>
		<pubDate>Sun, 02 Mar 2008 04:56:52 +0000</pubDate>
		<dc:creator>tadaya</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=1&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to <a href="http://wordpress.com/">WordPress.com</a>. This is your first post. Edit or delete it and start blogging!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/tadaya.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/tadaya.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tadaya.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tadaya.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tadaya.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tadaya.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tadaya.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tadaya.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tadaya.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tadaya.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tadaya.wordpress.com&amp;blog=3034445&amp;post=1&amp;subd=tadaya&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tadaya.wordpress.com/2008/03/02/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c42fc58d2ca5e183597ca3cf4118c9da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tadaya</media:title>
		</media:content>
	</item>
	</channel>
</rss>
