title: Using @Transactional annotation for hibernate application resulting in error
body: <p>I am trying to integrate spring with hibernate this morning. I want to use spring transaction manager. But getting the below error.  The error has something to do with @Trasactional Annotation. If i remove the annotation,im able to get the bean from the spring container.</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: com.sun.proxy.$Proxy19 cannot be cast to com.hibernate.dao.EvntDAOImpl
  at com.hibernate.action.HibernateAction.main(HibernateAction.java:17)
  </code></pre>
  
  <p>Im pasting below my source code.</p>
  
  <p><strong>POM.xml</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;hibernate-tutorials&lt;/groupId&gt;
  &lt;artifactId&gt;hibernate-tutorials&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;build&gt;
      &lt;sourceDirectory&gt;src&lt;/sourceDirectory&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;properties&gt;
      &lt;spring-framework.version&gt;4.0.3.RELEASE&lt;/spring-framework.version&gt;
      &lt;hibernate.version&gt;4.3.5.Final&lt;/hibernate.version&gt;
       &lt;slf4j.version&gt;1.7.5&lt;/slf4j.version&gt;
  &lt;/properties&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Spring ORM support --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;version&gt;${spring-framework.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Logging with SLF4J &amp; LogBack --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;${slf4j.version}&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;${hibernate.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.oracle&lt;/groupId&gt;
          &lt;artifactId&gt;ojdbc14&lt;/artifactId&gt;
          &lt;version&gt;10.2.0.2.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
          &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
          &lt;version&gt;1.4&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Hibernate Configuration</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>http://www.springframework.org/schema/beans/spring-beans.xsd
          <a href="http://www.springframework.org/schema/aop" rel="nofollow">http://www.springframework.org/schema/aop</a> <a href="http://www.springframework.org/schema/aop/spring-aop-4.0.xsd" rel="nofollow">http://www.springframework.org/schema/aop/spring-aop-4.0.xsd</a>
          <a href="http://www.springframework.org/schema/tx" rel="nofollow">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-4.0.xsd" rel="nofollow">http://www.springframework.org/schema/tx/spring-tx-4.0.xsd</a>"></p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
      &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
      &lt;property name="url" value="${url}" /&gt;
      &lt;property name="username" value="${username}" /&gt;
      &lt;property name="password" value="${password}" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="annotatedClasses"&gt;
          &lt;list&gt;
              &lt;value&gt;com.hibernate.model.Evnt&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager"
      class="org.springframework.orm.hibernatey.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>EvntDAOImpl.java</strong></p>
  
  <pre><code>package com.hibernate.dao;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Repository;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.hibernate.model.Evnt;
  
  @Repository(value="evntDAO")
  @Transactional
  public class EvntDAOImpl implements EvntDAO {
  
  @Autowired
  private SessionFactory sessionFactory;
  
  @Override
  public void storeEvnt(Evnt evnt) {
  
      sessionFactory.getCurrentSession().save(evnt);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>HibernateAction.java</p>
  
  <pre><code>package com.hibernate.action;
  
  import java.util.Date;
  
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  
  import com.hibernate.dao.EvntDAO;
  import com.hibernate.dao.EvntDAOImpl;
  import com.hibernate.model.Evnt;
  
  public class HibernateAction {
  
  public static void main(String[] args) {
      ApplicationContext context  = new         ClassPathXmlApplicationContext("applicationContext.xml");
  
      EvntDAOImpl evntDAO = (EvntDAOImpl) context.getBean("evntDAO");
      Evnt evnt = new Evnt();
      evnt.setTitle("first Event");
      evnt.setDate(new Date());
      evntDAO.storeEvnt(evnt);
  
      }
  }
  </code></pre>
  
  <p>Thanks in advance...</p>