首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Spring声明式事务配置错误时回滚的有关问题

2012-08-22 
Spring声明式事务配置异常时回滚的问题问题:spring 声明式事务,不能回滚多个操作的事务原因:在service方法

Spring声明式事务配置异常时回滚的问题
问题:spring 声明式事务,不能回滚多个操作的事务
原因:在service方法里面加了 try{} catch(){},
解决:要把try catch放到action里面

    //Controller    @Controller    @RequestMapping("/versionLable")    public class DeviceVersionLabelController    {        @Resource(name = "versLabelService")        DeviceVersionLabelService versionLabelService;                @RequestMapping("/synchronousdata")        public ModelAndView test(HttpServletRequest request,            HttpServletResponse response)        {                        try            {                versionLabelService.updateDeviceVersionLabel(hnInternetId,                 uploadResponse.getPath());            }            catch (Exception e)            {                // TODO Auto-generated catch block                e.printStackTrace();            }            return new ModelAndView("config/hnbversion_list");        }            }        //Service    @Service("versLabelService")    public class DeviceVersionLabelServiceImpl implements      DeviceVersionLabelService    {                @Resource        private DeviceVersionLabelDao deviceVerDao;                /**         * 更新数据版本标签 {@inheritDoc}         */        public void updateDeviceVersionLabel(String internetId, String fileName)        {            deviceVerDao.deleteSystemInfoLocal(internetId) throws Exception;                        deviceVerDao.updateSecLocal(internetId)  throws Exception;          }    }        //Dao    public interface DeviceVersionLabelDao    {        public void deleteSystemInfoLocal(String id)            throws Exception;                public void updateSecLocal(String id)            throws Exception;    }

热点排行