现在的位置: 首页 > 综合 > 正文

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

2013年10月24日 ⁄ 综合 ⁄ 共 378字 ⁄ 字号 评论关闭

在使用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

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

抱歉!评论已关闭.