2012-07-23 4 views
0

나는 봄 3과 4를 최대 절전 모드 사용하고 난 다음과 같이 XML로를 구성 :최대 절전 모드 4 봄 3 구성 문제

<?xml version="1.0" encoding="UTF-8"?> 

<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"> 

<bean id="propertiesConfigurer" 
     class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="locations"> 
      <list> 
       <value>/WEB-INF/conf/jdbc.properties</value> 
      </list> 
     </property> 
</bean> 



    <tx:annotation-driven transaction-manager="transactionManager"/> 
    <context:annotation-config /> 
    <context:component-scan base-package="com.friendsalert"/> 
    <aop:aspectj-autoproxy/> 

    <!--  
<bean id="log4jInitialization" 
    class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" > 
    <property name="targetClass" 
     value="org.springframework.util.Log4jConfigurer" /> 
    <property name="targetMethod" value="initLogging" /> 
    <property name="arguments"> 
     <list> 
      <value>/WEB-INF/conf/log4j.xml</value> 
      this value is bad for production. 
      <value>10000</value> 

     </list> 
    </property> 
</bean>  
--> 
<!-- ========================= RESOURCE DEFINITIONS ========================= --> 

<!-- Local Apache Commons DBCP DataSource that refers to a combined database --> 
<!-- (see dataAccessContext-jta.xml for an alternative) --> 
<!-- The placeholders are resolved from jdbc.properties through --> 
<!-- the PropertyPlaceholderConfigurer in applicationContext.xml--> 

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
    <property name="driverClassName" value="${jdbc.driverClassName}"/> 
    <property name="url" value="${jdbc.url}"/> 
    <property name="username" value="${jdbc.username}"/> 
    <property name="password" value="${jdbc.password}"/> 
    <property name="initialSize" value="${jdbc.initialSize}"/> 
    <property name="validationQuery" value="${jdbc.validationQuery}"/> 
    <property name="maxWait" value="${jdbc.maxWait}"/> 
    <property name="testOnBorrow" value="${jdbc.testOnBorrow}"/> 
    <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/> 
    <!-- property name="loginTimeout" value="${jdbc.loginTimeout}"/ --> 

</bean> 

<!-- Transaction manager for a single JDBC DataSource --> 
<!-- (see dataAccessContext-jta.xml for an alternative) 
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> 
    <property name="dataSource" ref="dataSource"/> 
</bean> 
--> 
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> 
    <property name="sessionFactory" ref="localSessionFactory"/> 
</bean> 


<bean id="localSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" depends-on="dataSource"> 
    <property name="dataSource" ref="dataSource"/> 
    <property name="mappingResources"> 
     <list> 
      <value>com/friendsalert/model/User.hbm.xml</value> 

     </list> 
    </property> 
    <property name="hibernateProperties"> 
     <props> 
      <!-- prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop --> 
      <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> 
      <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> 
      <prop key="hibernate.cache.use_second_level_cache">true</prop> 
      <prop key="hibernate.cache.provider_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop> 
      <prop key="hibernate.cache.use_query_cache">true</prop> 

       <!-- cache factory for hibernate 3.3 (surrently we use 3.2)--> 
      <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>        
      <prop key="hibernate.show_sql">true</prop> 
      <prop key="hibernate.connection.useUnicode">true</prop> 
      <prop key="hibernate.connection.charSet">UTF8</prop> 
      <!-- <prop key="hibernate.current_session_context_class">thread</prop>--> 
      <prop key="hibernate.connection.aggressive_release">false</prop>      
      <prop key="hibernate.connection.release_mode">after_transaction</prop> 
      <prop key="hibernate.connection.autocommit">true</prop> 
      <!-- create/drop.. use exporter class instead!--> 
      <prop key="hibernate.hbm2ddl.auto">update</prop> 
     </props> 
    </property> 
</bean> 

<bean id="userDao" class="com.friendsalert.dao.UserDao"> 
<property name="sessionFactory" ref="localSessionFactory"/>  
</bean> 



</beans> 

와 내가 DAO를 사용합니다. 내가 할 때 트랜잭션 (저장, 가져 오기, 업데이트) 그것은 처음 작동하고 두 번째 시간에 트랜잭션이 닫힙니다 오류가 발생합니다. 나는 모든 트랜잭션에 대해 왜 찾을 수없는 모든 함수에 대해 내 DAO에서 @Transactional 주석을 사용합니다.

아무도 내가 뭘 잘못했는지 말해 줄 수 있습니까?

감사

+0

Java 코드 및 스택 추적을 게시 할 수 있습니까? – ManuPK

답변

1

구성에 대한 특이한 사항은 다음과 같습니다

<prop key="hibernate.connection.aggressive_release">false</prop>      
<prop key="hibernate.connection.release_mode">after_transaction</prop> 
<prop key="hibernate.connection.autocommit">true</prop> 

난 그냥 그 선없이 시도 할 것입니다. 참조 문서에서

: 자동 커밋 모드는 (은 사용하지 않는 것이 좋습니다)
는 JDBC 풀링 된 커넥션들에 대해 자동 커밋을 활성화
hibernate.connection.autocommit하지 않는 것이 좋습니다. 예 : 사실 | false hibernate.connection.release_mode Hibernate가 JDBC 연결을 해제해야하는시기를 지정합니다. 기본적으로 JDBC 연결은 세션이 명시 적으로 닫히거나 연결이 끊어 질 때까지 보류됩니다. 응용 프로그램 서버 JTA 데이터 소스의 경우, after_statement를 사용하여 모든 JDBC 호출 이후에 적극적으로 연결을 해제하십시오. 비 JTA 연결의 경우, after_transaction을 사용하여 각 트랜잭션이 끝날 때 연결을 해제하는 것이 좋습니다. auto는 JTA 및 CMT 트랜잭션 전략에 대해 after_statement를 선택하고 JDBC 트랜잭션에 대해서는 after_transaction을 선택합니다.

관련 문제