title: what is the use of Hibernate Interceptor and proxyTargetClass
body: <p>I am a newbie to hibernate and spring and trying to learn the use of hibernate Interceptor .
  I went through community documentation which says that....</p>
  
  <blockquote>
    <p>This interceptor binds a new Hibernate Session to the thread before a
    method call, closing and removing it afterwards in case of any method
    outcome. If there already is a pre-bound Session (e.g. from
    HibernateTransactionManager, or from a surrounding
    Hibernate-intercepted method), the interceptor simply participates in
    it.</p>
  </blockquote>
  
  <p>But I am not able to understand when we use this and why we use this?</p>
  
  <p>when to create taskDao like this ?</p>
  
  <pre><code>&lt;bean name="abstractDao" abstract="true"&gt;
          &lt;property name="hibernateTemplate" ref="taskHibernateTemplate"/&gt;
      &lt;/bean&gt;
  &lt;bean id="taskHibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor"&gt;
          &lt;property name="sessionFactory" ref="taskSessionFactory"/&gt;
      &lt;/bean&gt;
  
  &lt;bean id="taskDaoTarget" class="com.xyz.abc.backgroundtask.impl.TaskDao" parent="abstractDao"/&gt;
  
  &lt;bean id="taskDao" class="org.springframework.aop.framework.ProxyFactoryBean"&gt;
      &lt;property name="proxyTargetClass" value="true"/&gt;
      &lt;property name="interceptorNames"&gt;
          &lt;list&gt;
              &lt;value&gt;taskHibernateInterceptor&lt;/value&gt;
              &lt;value&gt;taskDaoTarget&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and when to create taskDao like this ?</p>
  
  <pre><code>&lt;bean name="abstractDao" abstract="true"&gt;
          &lt;property name="hibernateTemplate" ref="taskHibernateTemplate"/&gt;
      &lt;/bean&gt;
  
  &lt;bean id="taskDao" class="com.xyz.zbc.backgroundtask.impl.TaskDao" parent="abstractDao"/&gt;
  </code></pre>