title: hibernate 4 and spring 3 configuration issue
body: <p>I use hibernate 4 with spring 3 and i configure it in xml like this:</p>
  
  <pre><code>&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"
      xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
          http://www.springframework.org/schema/aop
          http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt;
  
  &lt;bean id="propertiesConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="locations"&gt;
              &lt;list&gt;
                  &lt;value&gt;/WEB-INF/conf/jdbc.properties&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
  &lt;/bean&gt;
  
  
  
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
      &lt;context:annotation-config /&gt;
      &lt;context:component-scan base-package="com.friendsalert"/&gt;
      &lt;aop:aspectj-autoproxy/&gt;
  
      &lt;!--    
  &lt;bean id="log4jInitialization"
      class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"    &gt;
      &lt;property name="targetClass"
          value="org.springframework.util.Log4jConfigurer" /&gt;
      &lt;property name="targetMethod" value="initLogging" /&gt;
      &lt;property name="arguments"&gt;
          &lt;list&gt;
              &lt;value&gt;/WEB-INF/conf/log4j.xml&lt;/value&gt;
               this value is bad for production.
              &lt;value&gt;10000&lt;/value&gt;
  
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;    
   --&gt;
  &lt;!-- ========================= RESOURCE DEFINITIONS ========================= --&gt;
  
  &lt;!-- Local Apache Commons DBCP DataSource that refers to a combined database --&gt;
  &lt;!-- (see dataAccessContext-jta.xml for an alternative) --&gt;
  &lt;!-- The placeholders are resolved from jdbc.properties through --&gt;
  &lt;!-- the PropertyPlaceholderConfigurer in applicationContext.xml--&gt;
  
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
      &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt;
      &lt;property name="url" value="${jdbc.url}"/&gt;
      &lt;property name="username" value="${jdbc.username}"/&gt;
      &lt;property name="password" value="${jdbc.password}"/&gt;
      &lt;property name="initialSize" value="${jdbc.initialSize}"/&gt;
      &lt;property name="validationQuery" value="${jdbc.validationQuery}"/&gt;
      &lt;property name="maxWait" value="${jdbc.maxWait}"/&gt;
      &lt;property name="testOnBorrow" value="${jdbc.testOnBorrow}"/&gt;
      &lt;property name="testWhileIdle" value="${jdbc.testWhileIdle}"/&gt;
      &lt;!-- property name="loginTimeout" value="${jdbc.loginTimeout}"/ --&gt;
  
  &lt;/bean&gt;
  
  &lt;!-- Transaction manager for a single JDBC DataSource --&gt;
  &lt;!-- (see dataAccessContext-jta.xml for an alternative) 
  &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  --&gt;
  &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="localSessionFactory"/&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="localSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" depends-on="dataSource"&gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;com/friendsalert/model/User.hbm.xml&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.H2Dialect&lt;/prop --&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
              &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.EhCacheProvider&lt;/prop&gt; 
              &lt;prop key="hibernate.cache.use_second_level_cache"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.cache.provider_class"&gt;org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory&lt;/prop&gt;
              &lt;prop key="hibernate.cache.use_query_cache"&gt;true&lt;/prop&gt; 
  
                  &lt;!--  cache factory for hibernate 3.3 (surrently we use 3.2)--&gt;
              &lt;prop key="hibernate.cache.region.factory_class"&gt;org.hibernate.cache.ehcache.EhCacheRegionFactory&lt;/prop&gt;                              
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.connection.useUnicode"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.connection.charSet"&gt;UTF8&lt;/prop&gt;
              &lt;!--  &lt;prop key="hibernate.current_session_context_class"&gt;thread&lt;/prop&gt;--&gt;
              &lt;prop key="hibernate.connection.aggressive_release"&gt;false&lt;/prop&gt;                    
              &lt;prop key="hibernate.connection.release_mode"&gt;after_transaction&lt;/prop&gt;  
              &lt;prop key="hibernate.connection.autocommit"&gt;true&lt;/prop&gt;
              &lt;!--  create / drop.. use exporter class instead!--&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt; 
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="userDao" class="com.friendsalert.dao.UserDao"&gt;
  &lt;property name="sessionFactory" ref="localSessionFactory"/&gt;     
   &lt;/bean&gt;
  
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and i use dao. When i do a transaction(save, get, update) it works in the first time and in second time i get an error that the transaction is closed. 
  I use @Transactional annotation in my dao for every function so i can't find out why there is no transaction.</p>
  
  <p>can anybody tell me what i did wrong?</p>
  
  <p>thanks</p>