解决方案 »

  1.   

    这是没有事务的表现,因为调用的是SessionFactory.getCurrentSession()。不过楼主还在用spring啊,勇气可嘉
      

  2.   


    <aop:config>
    <aop:pointcut id="ServiceMethods"
    expression="execution(* com.hrmsys.service.impl..*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="ServiceMethods" />
    </aop:config>
      

  3.   

    楼主兄弟,这里的hibernate.current_session_context_class 应该没加载成功
      

  4.   

    这是applicationContext.xml的全部代码
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans   
            http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
            http://www.springframework.org/schema/context   
            http://www.springframework.org/schema/context/spring-context-3.1.xsd  
           http://www.springframework.org/schema/tx   
           http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
           http://www.springframework.org/schema/aop   
           http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
          "> <!-- 导入数据配置 -->
    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <value>classpath:jdbc.properties</value>
    </property>
    </bean>
    <!-- ****************************************数据源*************************************************************** -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <!-- 指定连接数据库的驱动 -->
    <property name="driverClass" value="${jdbc.driverClass}" />
    <!-- 指定连接数据库的URL -->
    <!-- &amp;zeroDateTimeBehavior=convertToNull是为了避免因数据库中为date类型的数据为0000-00-00, 
    若为此值hibernate会报错‘Cannot convert value '0000-00-00 00:00:00' from column 1 
    to TIMESTAMP’ -->
    <property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
    <!-- 指定连接数据库的用户名 -->
    <property name="user" value="${jdbc.username}" />
    <!-- 指定连接数据库的密码 -->
    <property name="password" value="${jdbc.password}" />
    <!-- 指定连接数据库连接池的最大连接数 -->
    <property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
    <!-- 指定连接数据库连接池的最小连接数 -->
    <property name="minPoolSize" value="${jdbc.minPoolSize}" />
    <!-- 指定连接数据库连接池的初始化连接数 -->
    <property name="initialPoolSize" value="${jdbc.initialPoolSize}" />
    <!-- 指定连接数据库连接池的连接的最大空闲时间 -->
    <property name="maxIdleTime" value="${jdbc.maxIdleTime}" />
    <!-- 指定隔多少秒检查所有连接池中的空闲连接,默认为0表示不检查 -->
    <property name="idleConnectionTestPeriod" value="18000" />
    </bean>
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <!-- <prop key="hibernate.hbm2ddl.auto">update</prop> -->
    <prop key="hibernate.jdbc.use_scrollable_resultset">false</prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">false</prop>
    <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext
    </prop>
    </props>
    </property>
    <property name="packagesToScan" value="com.hrmsys.entity" />
    </bean> <!-- 配置事务 begin -->
    <bean id="txManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean> <tx:advice id="txAdvice" transaction-manager="txManager">
    <tx:attributes>
    <tx:method name="update*" propagation="REQUIRED" read-only="false" />
    <tx:method name="delete*" propagation="REQUIRED" read-only="false" />
    <tx:method name="save*" propagation="REQUIRED" read-only="false" />
    <tx:method name="find*" propagation="REQUIRED" read-only="false" />
    <tx:method name="get*" propagation="REQUIRED" read-only="false" />
    <tx:method name="*" propagation="SUPPORTS" read-only="true" />
    </tx:attributes>
    </tx:advice> <aop:config>
    <aop:pointcut id="ServiceMethods"
    expression="execution(* com.hrmsys.service.impl..*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="ServiceMethods" />
    </aop:config>
    <!-- 配置事务 end --> <!-- 引入其它文件 -->
    <import resource="applicationContext-dao.xml" />
    <import resource="applicationContext-service.xml" />
    <import resource="applicationContext-action.xml" />
    </beans>
      

  5.   

    我设置了一个过滤器,这个会有影响吗?
    不会影响,不过劝你还是别用spring了,事务管理问题严重,这么多版本了,还是没有解决,我吃过亏的,还是用标准的东西吧。
      

  6.   

    我设置了一个过滤器,这个会有影响吗?
    不会影响,不过劝你还是别用spring了,事务管理问题严重,这么多版本了,还是没有解决,我吃过亏的,还是用标准的东西吧。
    不用spring用什么?
      

  7.   

    我设置了一个过滤器,这个会有影响吗?
    不会影响,不过劝你还是别用spring了,事务管理问题严重,这么多版本了,还是没有解决,我吃过亏的,还是用标准的东西吧。
    不用spring用什么?
    CDI,EJB,至于控制层,struts2倒是能用。
      

  8.   

    service层调用validateUser, 这个方法没有被切入事务