spring HibernateTemplate.save() 方法的自动提交问题

如题:

    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>
原文地址:https://www.cnblogs.com/myibm/p/7854337.html