正解
如果没有配全局的事物
你必须为每个insert update delete 做一次显式的提交

解决方案 »

  1.   

    我的DAO层是继承自HibernateDaoSupport,这个类没有实现事务的自动提交吗?如果没有, 假如我在spring配置文件applicationContext.xml中采用的是声明式的事务处理方式,
    如下:
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
     <property name="sessionFactory">
       <ref bean="sessionFactory"/>
     </property>
    </bean>
    <bean id="userDaoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
     <property name="transactionManager">
      <ref bean="transactionManager"/>
     </property>
     <property name="proxyInterfaces">
      <list>
       <value>com.jk.IUserDao</value>
      </list>
     </property>
     <property name="target">
      <list>
       <ref bean="userDao"/>
      </list>
     </property>
     <property name="transactionAttributes">
      <props>
       <prop key="insert*">PROPAGATION_REQUIRED</prop>
      </props>
     </property>
    </bean>这样的话,我如何在struts的action中应用这个事务代理呢?
    是采用setter和getter的方式让spring自动注入一个吗?还是采用如下的方式调用?
    ApplicationContext context=new ClassPathXmlApplicationContext("***")
    IUserDao userDao=(IUserDao)context.getBean("userDaoProxy");
    useDao.save(***)两种我都试过了,都不行,是不是我哪里写错了?
    请前辈们指点一下........
      

  2.   

    你测试一下
    在你的BBuser里面有值吗 是否主键已经存在 或是没有值
    如果没有问题 那就是食物的问题你在事务中在吧BBuser的hbm.xml的配置加上
      

  3.   

    bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="eventListeners">
                <map>
                    <entry key="post-update">
                        <ref local="historyListener"/>
                    </entry>
                </map>
            </property>        <property name="mappingDirectoryLocations">
                <list>
                    <value>classpath*:/com/cnc/combine/plugins/menu/domain/hbm/</value>
                    <value>classpath*:/com/cnc/combine/plugins/security/domain/hbm/</value>
                    <value>classpath*:/com/cnc/oa/domain/hbm/</value>                
                </list>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                    <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
                    <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
                </props>
            </property>
        </bean>
    你参照下 试试