关于no transaction is in progress错误的解决方法

来源:互联网 发布:安畅网络认证 编辑:程序博客网 时间:2024/06/08 17:51

在使用spring +jpa开发中

结构dao+service+action三层

dao继承basedao

basedao中写了方法 public T merge(T entity) {  T returnObj = this.getJpaTemplate().merge(entity);  this.getJpaTemplate().flush();  return returnObj; }


在service中自动注入dao

 @Autowired private CityDao cityDao @Transactional public City merge (City city){  if (city == null)   return city;  return cityDao.merge(city); }

如果不写@Transactional就报错,no transaction is in progress

写上就正常,原因调查中。。。

原创粉丝点击