<?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>Technotrance, Illusions and Perspectives &#187; Uncategorized</title>
	<atom:link href="http://myblog.shriharisc.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://myblog.shriharisc.com</link>
	<description>A dose of everyday bruises with Java/JEE</description>
	<lastBuildDate>Mon, 12 Jul 2010 17:55:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tip: Listing and Compressing modified files on SVN since latest update on Linux</title>
		<link>http://myblog.shriharisc.com/2009/11/26/tip-getting-list-of-files-modified-on-svn-since-latest-update-on-linux/</link>
		<comments>http://myblog.shriharisc.com/2009/11/26/tip-getting-list-of-files-modified-on-svn-since-latest-update-on-linux/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 12:52:17 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[shell-script]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://myblog.shriharisc.com/?p=217</guid>
		<description><![CDATA[In order to find or look at the list of all the modified files on SVN (since the last update) on any Linux host, you may use the following command (say we need to find java or xhtml files) 


svn status -u &#124; grep -e &#039;.java&#039; -e &#039;.xhtml&#039; &#124; awk &#039;{if($2 ~/^[0-9]+$/) {print $3} else [...]]]></description>
			<content:encoded><![CDATA[<p>In order to find or look at the list of all the modified files on SVN (since the last update) on any Linux host, you may use the following command (say we need to find java or xhtml files) </p>
<pre class="brush: bash">

svn status -u | grep -e &#039;.java&#039; -e &#039;.xhtml&#039; | awk &#039;{if($2 ~/^[0-9]+$/) {print $3} else {print $2}}&#039;
</pre>
<p>This command would also print the unversioned (not added to SVN) files as well. Now if you want to compress these list of files (using tar), issue the following shell command:</p>
<pre class="brush: bash">

svn status -u | grep -e &#039;.java&#039; -e &#039;.xhtml&#039; | awk &#039;{if($2 ~/^[0-9]+$/) {print $3} else {print $2}}&#039; | xargs tar cvfz modifiedfiles.tar.z
</pre>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/11/26/tip-getting-list-of-files-modified-on-svn-since-latest-update-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom injection example in Google Guice</title>
		<link>http://myblog.shriharisc.com/2009/07/10/custom-injection-example-in-google-guice/</link>
		<comments>http://myblog.shriharisc.com/2009/07/10/custom-injection-example-in-google-guice/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 12:11:19 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[google-guice]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=64</guid>
		<description><![CDATA[Google Guice supports custom injections using 2 endpoints: type listener and injection listener and registeration of end-points. You may read the whole theory behind here, where a Logging Injection using Log4J is explained.
Lets try to implement that and see what more is required. In order to test the whole exercise, we could embrace TestNG to [...]]]></description>
			<content:encoded><![CDATA[<p>Google Guice supports custom injections using 2 endpoints: type listener and injection listener and registeration of end-points. You may read the <a title="Google Guice Custom Injections" href="http://code.google.com/p/google-guice/wiki/CustomInjections">whole theory behind here</a>, where a Logging Injection using Log4J is explained.</p>
<p>Lets try to implement that and see what more is required. In order to test the whole exercise, we could embrace TestNG to write a sample unit test-case using a dummy class have a method.   Lets write a simple class which uses the Log4J Logger instance, injected using InjectLogger.</p>
<pre class="brush: java">
public class LoggingUsage  
{   @InjectLogger org.apache.log4j.Logger log;
     public int doAddition(int a,int b)
     {      int c = a+b;
           log.info(&quot;Added result: &quot;+c);
           return c;
     }
}
</pre>
<p>Lets us now a write a TestNG testcase to try and test the same.<br />
public class CustomLoggerInjectionTest<br />
{    LoggingUsage logUsage;<br />
     @BeforeMethod<br />
     public void initLogUsage()<br />
    {     logUsage = Guice.createInjector(new LoggerModule(),new MyLoggerModule()).getInstance(LoggingUsage.class);<br />
    }</p>
<p>    @Test<br />
    public void testLogUsage()<br />
    {   int value = logUsage.doAddition(20, 15);<br />
        assertEquals(value,35);<br />
    }</p>
<p>   static class MyLoggerModule extends AbstractModule<br />
   {   @Override<br />
        protected void configure()<br />
        {      bind(LoggingUsage.class);<br />
        }<br />
    }<br />
}<br />
[/sourcecode]<br />
Lets examine this testcase. Just before test execution, we register the LoggerModule, which binds the LOG4J specific listeners (type/injections) and custom module to bind our custom class which needs Logger injection we wrote above, and instantiate the class that uses this Logger instance. When the test executes, the usage-class would already have a injected Logger and would execute without issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/07/10/custom-injection-example-in-google-guice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using enums in DWR to populate select or multi-select</title>
		<link>http://myblog.shriharisc.com/2009/07/06/using-enums-in-dwr-to-populate-select-or-multi-select/</link>
		<comments>http://myblog.shriharisc.com/2009/07/06/using-enums-in-dwr-to-populate-select-or-multi-select/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 18:04:04 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dwr]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=61</guid>
		<description><![CDATA[In case we need to population enumeration data in combo  box or multi-select widgets, in DWR (integrated on Spring), following is the approach:
1) In the spring&#8217;s applicationContext.
a) Add the method which returns the enum entity to &#60;dwr:remote&#62;
b) Add a dwr:convert tag of type &#8216;enum&#8217; (as below)

&#60;dwr:remote javascript=&#34;myoperations&#34;&#62;
   &#60;dwr:include method=&#34;getDataAsEnum&#34;/&#62;
   &#60;dwr:convert type=&#34;enum&#34;/&#62;
&#60;/dwr:remote&#62;

2) [...]]]></description>
			<content:encoded><![CDATA[<p>In case we need to population enumeration data in combo  box or multi-select widgets, in DWR (integrated on Spring), following is the approach:</p>
<p>1) In the spring&#8217;s applicationContext.<br />
a) Add the method which returns the enum entity to &lt;dwr:remote&gt;<br />
b) Add a dwr:convert tag of type &#8216;enum&#8217; (as below)</p>
<pre class="brush: xml">
&lt;dwr:remote javascript=&quot;myoperations&quot;&gt;
   &lt;dwr:include method=&quot;getDataAsEnum&quot;/&gt;
   &lt;dwr:convert type=&quot;enum&quot;/&gt;
&lt;/dwr:remote&gt;
</pre>
<p>2) In the view (jsp) file, you could invoke the following javascript function </p>
<pre class="brush: javascript">
&lt;body onload=&quot;loadEnumeration();&quot;&gt;
function loadEnumeration()
{ myOperations.getDataAsEnum(callbackFunctionHandle);
};
var callbackFunctionHandle = function(data)
{   dwr.util.removeAllOptions(&#039;enum_select&#039;);
     dwr.util.addOptions(&#039;enum_select&#039;,[&#039;--Select--&#039;]);
     dwr.util.addOptions(&#039;enum_select&#039;, data);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/07/06/using-enums-in-dwr-to-populate-select-or-multi-select/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resolving conflicts on DWR with jQuery</title>
		<link>http://myblog.shriharisc.com/2009/07/04/resolving-conflicts-on-dwr-with-jquery/</link>
		<comments>http://myblog.shriharisc.com/2009/07/04/resolving-conflicts-on-dwr-with-jquery/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 11:11:32 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=56</guid>
		<description><![CDATA[Since DWR&#8217;s util.js uses $ as an alias to &#8216;dwr.util.byId&#8217; function, it may not have a smooth integration with jQuery as $ is also used by the latter as a function alias. In order to resolve this conflict, one could follow snippet:
&#60;script type='text/javascript' src='/mycontext/js/jquery-1.3.2.min.js'&#62;&#60;/script&#62;
&#60;script type="text/javascript"&#62;
    var jq = jQuery.noConflict();
&#60;/script&#62;
&#60;script type='text/javascript' src='/mycontext/dwr/engine.js'&#62;&#60;/script&#62;
&#60;script type='text/javascript' [...]]]></description>
			<content:encoded><![CDATA[<p>Since DWR&#8217;s util.js uses $ as an alias to &#8216;dwr.util.byId&#8217; function, it may not have a smooth integration with jQuery as $ is also used by the latter as a function alias. In order to resolve this conflict, one could follow snippet:</p>
<pre>&lt;script type='text/javascript' src='/mycontext/js/jquery-1.3.2.min.js'&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    var jq = jQuery.noConflict();
&lt;/script&gt;
&lt;script type='text/javascript' src='/mycontext/dwr/engine.js'&gt;&lt;/script&gt;
&lt;script type='text/javascript' src='/mycontext/dwr/util.js'&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
   jq(document).ready(function()
   {  //other function calls
   });
&lt;/script&gt;</pre>
<p>&#8216;jq&#8217; variable defined in place of $ to invoke the rest of other jQuery functions.</p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:0;width:1px;height:1px;">dwr/util.jsfor</div>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/07/04/resolving-conflicts-on-dwr-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrating PrimeFaces with GuiceyFruit on JPA</title>
		<link>http://myblog.shriharisc.com/2009/07/01/integrating-primefaces-with-guiceyfruit-on-jpa/</link>
		<comments>http://myblog.shriharisc.com/2009/07/01/integrating-primefaces-with-guiceyfruit-on-jpa/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 18:47:43 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=51</guid>
		<description><![CDATA[Following suggestions from James Stratchan and Catagay Civici, I set my foot to integrate GuiceyFruit with JPA for the PrimeFaces tutorial I wrote.  You could download the example hosted there and try it. Here are the steps I followed on that Book-Store example and ended up with a cool working code.
1) Add the following repository [...]]]></description>
			<content:encoded><![CDATA[<p>Following suggestions from<a href="http://macstrac.blogspot.com/"> James Stratchan</a> and <a href="http://cagataycivici.wordpress.com/">Catagay Civici,</a> I set my foot to integrate <a href="http://code.google.com/p/guiceyfruit/">GuiceyFruit</a> with JPA for the <a href="http://www.talentattest.com/texam/extui/tutorialview.seam?tutorialid=19">PrimeFaces tutorial I wrote</a>.  You could download the example hosted there and try it. Here are the steps I followed on that Book-Store example and ended up with a cool working code.</p>
<p>1) Add the following repository to pom.xml</p>
<pre><span style="color:#0000ff;">&lt;repository&gt;
 &lt;id&gt;guiceyfruit.release&lt;/id&gt;
 &lt;name&gt;GuiceyFruit Release Repository&lt;/name&gt;
 &lt;url&gt;http://guiceyfruit.googlecode.com/svn/repo/releases/&lt;/url&gt;
 &lt;snapshots&gt;
 &lt;enabled&gt;false&lt;/enabled&gt;
 &lt;/snapshots&gt;
 &lt;releases&gt;
 &lt;enabled&gt;true&lt;/enabled&gt;
 &lt;/releases&gt;
 &lt;/repository&gt;</span></pre>
<p>2) Add the following dependencies</p>
<pre><span style="color:#0000ff;">&lt;dependency&gt;
 &lt;groupId&gt;org.guiceyfruit&lt;/groupId&gt;
 &lt;artifactId&gt;guiceyfruit-jpa&lt;/artifactId&gt;
 &lt;version&gt;2.0-beta-7&lt;/version&gt;
 &lt;/dependency&gt;</span></pre>
<p>3)  Comment/remove the following dependency</p>
<pre><span style="color:#0000ff;">&lt;!--dependency&gt;
 &lt;groupId&gt;com.google.code.guice&lt;/groupId&gt;
 &lt;artifactId&gt;guice&lt;/artifactId&gt;
 &lt;version&gt;1.0&lt;/version&gt;
 &lt;/dependency&gt;

 &lt;dependency&gt;
 &lt;groupId&gt;aopalliance&lt;/groupId&gt;
 &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
 &lt;version&gt;1.0&lt;/version&gt;
 &lt;/dependency--&gt;</span></pre>
<p>4) Open the dataservice bould concrete implementation (e.g. BookStoreImpl in the example) and replace @Inject with @javax.persistence.PeristenceContext.</p>
<pre><span style="color:#0000ff;">public class BookStoreImpl implements BookStore
{  @PersistenceContext()
   private EntityManager em;</span>
<span style="color:#0000ff;">}</span></pre>
<p>5)  Open the WEB-INF/web.xml and modify the context-param &#8216;optimus.CONFIG_MODULES&#8217;  like this</p>
<pre><span style="color:#0000ff;">&lt;context-param&gt;
 &lt;param-name&gt;optimus.CONFIG_MODULES&lt;/param-name&gt;
 &lt;param-value&gt;com.ts.pfaces.core.BookStoreModule
 ,org.primefaces.optimus.persistence.JPAModule
 ,org.guiceyfruit.jpa.JpaModule
 &lt;/param-value&gt;
 &lt;/context-param&gt;</span></pre>
<p>And voila it works!</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/07/01/integrating-primefaces-with-guiceyfruit-on-jpa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing a Unitils DAO testing infrastructure for Spring and JPA on TestNG</title>
		<link>http://myblog.shriharisc.com/2009/06/29/implementing-a-unitils-dao-testing-infrastructure-for-spring-and-jpa-on-testng/</link>
		<comments>http://myblog.shriharisc.com/2009/06/29/implementing-a-unitils-dao-testing-infrastructure-for-spring-and-jpa-on-testng/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 17:50:51 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[unitils]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=47</guid>
		<description><![CDATA[Unitils provides an excellant infrastructure for unit testing DAO (and data-service) layers  for Spring as IoC Framework on all the component unit testing frameworks such as JUnit 3, JUnit4 and TestNG, without any boilerplate code or coniguration hassles. We will look at establishing a testing infrastructure for Spring with JPA on TestNG frmaework.
Suppose the custom [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://unitils.org">Unitils</a></strong> provides an excellant infrastructure for unit testing DAO (and data-service) layers  for Spring as IoC Framework on all the component unit testing frameworks such as JUnit 3, JUnit4 and TestNG, without any boilerplate code or coniguration hassles. We will look at establishing a testing infrastructure for Spring with JPA on TestNG frmaework.</p>
<p>Suppose the custom DAO and its implementation definition are like this (with regard to semantics of Spring JPA integration)</p>
<pre><span style="color:#0000ff;"><code>package mypackage;
public CustomDAO
{    public List findAll();
     public void save(Entity eo);
}</code></span></pre>
<pre><span style="color:#0000ff;">package mypackage;
public CustomDAOImpl implements CustommmDAO
{   @PersistenceContext
    private EntityManager em;</span></pre>
<pre><span style="color:#0000ff;">    //all other method implementations..
      ....
}</span></pre>
<p>In order to setup a Unitils test infrastructure on TestNG, the following is the class-template:</p>
<pre><span style="color:#0000ff;"><code>public class CustomDAOTestCase extends UnitilsTestNG
{   /**
     * Injects a test specific application context configuration
     */
    @SpringApplicationContext
    public ConfigurableApplicationContext createApplicationContext()
    {  return new ClassPathXmlApplicationContext("applicationContext-test.xml");
    }</code></span></pre>
<pre><span style="color:#0000ff;">     @SpringBean("customDAO")
     private CustomDAO customDAO;</span></pre>
<pre><span style="color:#0000ff;">     //all @Test annotated methods..</span></pre>
<pre><span style="color:#0000ff;">      @Override
      protected void unitilsAfterTestTearDown(java.lang.reflect.Method method)
      {}
}</span></pre>
<p>for which the following would be the test specific Spring&#8217;s application context confguration (applicationContext-test.xml)</p>
<pre><span style="color:#0000ff;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;

 &lt;bean id="entityManagerFactory" &gt;
 &lt;property name="persistenceXmlLocation" value="persistence-test.xml"/&gt;
 &lt;property name="persistenceUnitName" value="customservice-test"/&gt;
 &lt;/bean&gt;

 &lt;bean id="transactionManager"&gt;
 &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
 &lt;/bean&gt;

 &lt;tx:annotation-driven /&gt;

 &lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/&gt;

 &lt;bean id="customDAO" class="mypackage.CustomDAOImpl"/&gt;
&lt;/beans&gt;</span></pre>
<p>Look specifically at entityManagerFactory bean definition, org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean allows us to load test specific persistence.xml which could allow us to maintain more than onne persistence context for a sample application.<br />
These two definitions extend the Spring&#8217;s JPA capabilities for unit testing DAO on Unitils infrastructure!</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/06/29/implementing-a-unitils-dao-testing-infrastructure-for-spring-and-jpa-on-testng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Overcoming pitfalls with Query cache in Hibernate</title>
		<link>http://myblog.shriharisc.com/2009/06/27/overcoming-pitfalls-with-query-cache-in-hibernate/</link>
		<comments>http://myblog.shriharisc.com/2009/06/27/overcoming-pitfalls-with-query-cache-in-hibernate/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 17:41:43 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[query-cache]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=44</guid>
		<description><![CDATA[Query caching in Hibernate used to cache query state and results, has  multiple shortcomings if, not used judiciously. Some of the common pitfalls include:
(i) Query Cache structural representation is a QueryKey mapped to Object[][] (2-dimensional)  and holds majority of persistent object references. QueryKey represents query specific data such as the SQL Query text with parameters [...]]]></description>
			<content:encoded><![CDATA[<p>Query caching in Hibernate used to cache query state and results, has  multiple shortcomings if, not used judiciously. Some of the common pitfalls include:</p>
<p>(i) Query Cache structural representation is a QueryKey mapped to Object[][] (2-dimensional)  and holds majority of persistent object references. QueryKey represents query specific data such as the SQL Query text with parameters (positional/named). QueryKey representation would get deteriorated if parameters represent entity object or a deep rooted object hierarchy.</p>
<p>(ii) If multiple equivalents of load() is invoked,  there could potentially create multiple parameter versions of QueryKey containing equivalent duplicate entity objects exist in the cache.</p>
<p>Following are the patterns and practices that could be followed to fix these shortcomings:</p>
<p>1) Decorate <strong>org.hibernate.cache.StandardQueryCache </strong>and override the put() method to check if a canonical equivalent of a query results object already exist in the Object[][], and assign the same QueryKey if it exists. One needs to implement <strong>org.hibernate.cache.QueryCacheFactory</strong> also to plug into the Hibernate config.</p>
<p>2) Refactor the code to set entity&#8217;s keys as query parameters, rather than setting the entire entity object. Critreia representations should also use identifiers as parameters.</p>
<p>3) Write HQL queries to use identifiers in any substitutable parameters such as WHERE clause, IN clause etc.</p>
<p>4) Use positional parameters over named parameters as it could prevent using string pools.</p>
<p>5) If you are in a single JVM using in memory cache only, use <em><span style="font-family:Courier New;">hibernate.cache.use_structured_entries=false</span></em> in your hibernate configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/06/27/overcoming-pitfalls-with-query-cache-in-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hibernate Session&#039;s get() annd load() comparison</title>
		<link>http://myblog.shriharisc.com/2009/06/27/hibernate-sessions-get-annd-load-comparison/</link>
		<comments>http://myblog.shriharisc.com/2009/06/27/hibernate-sessions-get-annd-load-comparison/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 18:43:39 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=41</guid>
		<description><![CDATA[These are the differences I could readily understand when I was comparing the runtime behaviour of Hibernate Session&#8217;s get and load methods.
a)    get() does a database hit as soon as the method is called, load() makes a database hit, only if one of the field in the entity is called.
b)    load() should be used when [...]]]></description>
			<content:encoded><![CDATA[<p>These are the differences I could readily understand when I was comparing the runtime behaviour of Hibernate Session&#8217;s get and load methods.</p>
<p>a)    get() does a database hit as soon as the method is called, load() makes a database hit, only if one of the field in the entity is called.</p>
<p>b)    load() should be used when the entity is assured that it exists in the database, else get() should be called. If an non-existent primary key is passed, get() returns a null directly. However passing a non-existing primary key to load() returns you a non-null entity object, but would throw this exception when a field of that entity is referenced: <span style="color:#0000ff;">org.hibernate.ObjectNotFoundException: No row with the given identifier exists. </span></p>
<p>c)    calling a field in the entity in load() method after getTransaction().commit(), would throw a<span style="color:#0000ff;"> LazyInitializationException (could not initialize proxy &#8211; no Session).</span></p>
<p><span style="color:#0000ff;"><br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/06/27/hibernate-sessions-get-annd-load-comparison/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependency Injection&#039;s equivalent Java reflection invocations</title>
		<link>http://myblog.shriharisc.com/2009/06/24/dependency-injections-equivalent-java-reflection-invocations/</link>
		<comments>http://myblog.shriharisc.com/2009/06/24/dependency-injections-equivalent-java-reflection-invocations/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 18:16:17 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=38</guid>
		<description><![CDATA[As we know that there are 3 types of injections supported by any IoC framework, following are the equivalent function points in the reflection package (java.lang.reflect):
1) Constructor Injection -  &#60;T&#62; Constructor.newInstance(Object... initargs)
2) Method Injection    -     Object Method.invoke(Object obj, Object... args)
3) Field Injection -  void Field.set(Object obj, Object value)
Interestingly all these reflection classes are subclasses [...]]]></description>
			<content:encoded><![CDATA[<p>As we know that there are 3 types of injections supported by any IoC framework, following are the equivalent function points in the reflection package (java.lang.reflect):</p>
<pre><span style="color:#0000ff;">1) Constructor Injection -  &lt;T&gt; Constructor.newInstance(Object... initargs)</span>
<span style="color:#0000ff;">2) Method Injection    -     Object Method.invoke(Object obj, Object... args)</span>
<span style="color:#0000ff;">3) Field Injection -  void Field.set(Object obj, Object value)</span></pre>
<p>Interestingly all these reflection classes are subclasses of <span style="color:#0000ff;">java.lang.reflect.AccessibleObject</span> and are final.  Also the complete mechanics of Injection semantics hinges on the accessible flag defined in<span style="color:#0000ff;"> java.lang.reflect.AccessibleObject.</span> Please see javadocs for effective explanation.</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/06/24/dependency-injections-equivalent-java-reflection-invocations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Google Guice to inject JPA EntityManager</title>
		<link>http://myblog.shriharisc.com/2009/06/23/using-google-guice-to-inject-jpa-entitymanager/</link>
		<comments>http://myblog.shriharisc.com/2009/06/23/using-google-guice-to-inject-jpa-entitymanager/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 17:54:26 +0000</pubDate>
		<dc:creator>Shrihari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://schakrap.wordpress.com/?p=35</guid>
		<description><![CDATA[I am working on an persistence example using PrimeFaces, Google Guice and Hibernate. Following are the four steps to inject a JPA EntityManager into the Manager  (Appfuse parlance) / DAO Layer:
1) Define META-INF/persistence.xml containing JPA Configuration (similar to hibernate.cfg.xml)
&#60;?xml version="1.0" encoding="UTF-8"?&#62;
&#60;persistence xmlns="http://java.sun.com/xml/ns/persistence"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
 version="1.0"&#62;

 &#60;persistence-unit name="persdb" transaction-type="RESOURCE_LOCAL"&#62;
 &#60;provider&#62;org.hibernate.ejb.HibernatePersistence&#60;/provider&#62;
 &#60;properties&#62;
 ...
 &#60;/properties&#62;
 &#60;/persistence-unit&#62;

&#60;/persistence&#62;
2) Create [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on an persistence example using PrimeFaces, Google Guice and Hibernate. Following are the four steps to inject a JPA EntityManager into the Manager  (Appfuse parlance) / DAO Layer:</p>
<p>1) Define META-INF/persistence.xml containing JPA Configuration (similar to hibernate.cfg.xml)</p>
<pre><span style="color:#0000ff;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
 version="1.0"&gt;

 &lt;persistence-unit name="persdb" transaction-type="RESOURCE_LOCAL"&gt;
 &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
 &lt;properties&gt;
 ...
 &lt;/properties&gt;
 &lt;/persistence-unit&gt;

&lt;/persistence&gt;</span></pre>
<p>2) Create a startup controller Guice bean</p>
<pre><span style="color:#0000ff;">@Controller(name="startupBean", startup=true)
public class StartupBean
{    public StartupBean()
      {}
}</span></pre>
<p>3) Create a Google Guice Module</p>
<pre><span style="color:#0000ff;">public class MyModule implements Module
{       public void configure(Binder binder)
          {   AnnotatedBindingBuilder bindingBuilder = binder.bind(MyDataService.class);
              ScopedBindingBuilder scopedBuilder = bindingBuilder.to(MyDataServiceImpl.class);
              scopedBuilder.in(SINGLETON);
          }
}</span></pre>
<p>and create a context parameter in WEB-INF/web.xml</p>
<pre><span style="color:#0000ff;">&lt;context-param&gt;
 &lt;param-name&gt;optimus.CONFIG_MODULES&lt;/param-name&gt;
 &lt;param-value&gt;mypackage.MyModule,org.primefaces.optimus.persistence.JPAModule
 &lt;/param-value&gt;
 &lt;/context-param&gt;</span></pre>
<p>Note: org.primefaces.optimus.persistence.JPAModule actually injects the EntityManager reading the META-INF/persistence.xml</p>
<p>4) Create the DaraService implementation containing the injected EntityManager</p>
<pre><span style="color:#0000ff;">public class MyDataServiceImpl implements MyDataService
{        @Inject
            private EntityManager em;</span>
<span style="color:#0000ff;">           //all methods using JPA entityManager here
</span>
<span style="color:#0000ff;">}</span></pre>
<p>No other configuration xmls to be changed. Ain&#8217;t it cool!</p>
]]></content:encoded>
			<wfw:commentRss>http://myblog.shriharisc.com/2009/06/23/using-google-guice-to-inject-jpa-entitymanager/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
