如题:

    service1:

           dao1.save(obj);   //失败,应该给spring捕获,但没有,程序继续执行下去了。

           redisService.fun1();  //被执行

    service2:

           dao1.update(obj);   //失败,错误给spring捕获,抛出异常,程序终止。

           redisService.fun1();

经过查找相关资料,确认是因为数据库表主键的问题
        <id name="id" type="java.lang.String">
            <column name="id" length="20" />
            <generator class="assigned" />
        </id>
当class="assigned"时使用getHibernateTemplate().save()是不能插入数据到数据库。
hibernate.xml配置文件里加上如下属性

hibernate.connection.autocommit=true
或者如下:
<property name="connection.autocommit">true </property>

相关文章:

  • 2021-09-05
  • 2021-11-18
  • 2022-03-09
  • 2022-12-23
  • 2022-12-28
  • 2021-11-25
  • 2021-08-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-03
  • 2021-04-17
  • 2021-06-01
  • 2021-11-26
  • 2022-12-23
  • 2021-10-25
相关资源
相似解决方案