spring 3 hibernate 4 配置 用spring做事务管理,事务提交前Connection关闭

yangcy 发布于 2013/07/31 22:20
阅读 1K+
收藏 0

事务提交前Connection关闭 请问大家这是什么原因导致的?

Caused by: org.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: commit failed

    at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:561)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:478)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:272)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
    at $Proxy14.updateSystemResources(Unknown Source)
    ... 54 more

Caused by: org.hibernate.TransactionException: commit failed

下面是配置文件

<?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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:spring-beans-3.0.xsd
            http://www.springframework.org/schema/context classpath:spring-context-3.0.xsd
            http://www.springframework.org/schema/tx classpath:spring-tx-3.0.xsd
            http://www.springframework.org/schema/jdbc classpath:spring-jdbc-3.0.xsd">
    
    <context:annotation-config />
    
    <context:component-scan base-package="soy.server.support" />
    
    <bean id="lobHandler" lazy-init="true" class="org.springframework.jdbc.support.lob.DefaultLobHandler"/>
        
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>

        <property name="mappingLocations">
            <bean class="soy.server.service.HbmMappingFactoryBean">
                <constructor-arg index="0">
                    <value>org.springframework.core.io.ClassPathResource</value>
                </constructor-arg>
            </bean>
        </property>
       
        <property name="packagesToScan">
            <list>
                <value>soy.server.model</value>
            </list>
        </property>        
      
        <property name="hibernateProperties">
            <bean class="org.springframework.beans.factory.config.PropertiesFactoryBean">
                <property name="location">
                    <value>classpath:hibernate.properties</value>
                </property>
            </bean>
        </property>

        <property name="entityInterceptor">
            <ref bean="trackingDBHibernateInterceptor"/>
        </property>    
        <!--
        <property name="lobHandler">
            <ref bean="lobHandler"/>
        </property>    
         -->                
    </bean>
<!--    
    <bean id="trackingDBHibernateInterceptor" class="soy.server.support.TrackingDBHibernateInterceptor"/>
-->

    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref bean="sessionFactory"/>
        </property>
    </bean>
    
    <tx:annotation-driven transaction-manager="transactionManager"/>
   
hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext


加载中
返回顶部
顶部