spring+hibernate

时间:2023-03-09 03:48:31
spring+hibernate

添加注解时spring是添加在set方法上而hibernate是添加在get方法上

事务应该加在service层上,而不是加在dao层上,如果加在dao层上回滚的时候只能回滚一个dao的实现。

事务处理过程中遇到RuntimeException时会自动回滚。

@Transactional的properties中最重要的是事务的传播特性propagation,默认值是REQUIRED

Support a current transaction, create a new one if none exists.