日期:2014-05-20  浏览次数:20708 次

事务没提交
我的配置文件
XML code
<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-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
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
           

    <!--  配置SessionFactory -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <!-- 使用本地的hibernate.cfg.xml配置文件,这样清晰一点 -->
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
    </bean>
    

    <bean id="userDao" class="com.singleusers.dao.impl.UserDaoImpl">
        <property name="sessionFactory" ref="sessionFactory">        
        </property>
    </bean> 
    <bean id="userService" class="com.singleusers.service.impl.UserServiceImpl">
        <property name="userDao" ref="userDao"></property>
    </bean>

    <bean id="addUserAction" class="com.singleusers.adduser.action.AddUserAction">
        <property name="service" ref="userService"></property>
    </bean>    <!-- -->
    
    
    
    <!-- 配置事物管理器 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
 
    <!-- AOP,那些包下面的类需要使用事物管理器 -->
    <aop:config>
        <aop:pointcut id="servieMethod"
            expression="execution(* com.singleusers.service.*.*(..))" />
        <!-- 如果满足servieMethod这个切入点就去 参考事物传播性配置的txAdvice建议-->
        <aop:advisor advice-ref="txAdvice" pointcut-ref="servieMethod" />
    </aop:config>

    <!-- 事物传播性配置 -->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <!--
                propagation="REQUIRED" 当前有事物则加入,否则新建一个事物,read-only="true" 事物是否只读
            -->
            <tx:method name="get*" read-only="true" />
            <tx:method name="find*" read-only="true" />
            <tx:method name="add*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="del*" propagation="REQUIRED" />
        </tx:attributes>
    </tx:advice>
</beans>



执行了
Hibernate: 
  insert 
  into
  userid
  (name, password, tel) 
  values
  (?, ?, ?)
但事务没提交 被锁定了 这是啥原因啊?

------解决方案--------------------
expression="execution(* com.singleusers.service.*.*(..))" />