必须加@Transactional事务注解才能成功插入数据,原因未知。
2016-03-10 13:42
429 查看
项目名:patentFlowManagementProject
如果不加事务注解,数据插入失败而且无任何报错,很诡异。
如果不加事务注解,数据插入失败而且无任何报错,很诡异。
@Override @Transactional public void joinPrefecture(String prefectureId, String userId) throws Exception { Prefecture prefecture = findById(Prefecture.class, prefectureId); Applicant applicant = findById(Applicant.class, userId); PrefectureApplicant prefectureApplicant = new PrefectureApplicant(); prefectureApplicant.setId(UUIDGenerator.randomUUID()); prefectureApplicant.setType("applying"); prefectureApplicant.setPrefecture(prefecture); prefectureApplicant.setApplicant(applicant); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); prefectureApplicant.setTime(simpleDateFormat.format(new Date(System.currentTimeMillis()))); System.out.println(prefectureApplicant.toString()); System.out.println(prefectureApplicant.getId()); System.out.println(prefectureApplicant.getTime()); System.out.println(prefectureApplicant.getType()); save(prefectureApplicant); }
相关文章推荐
- SQL Server误区30日谈 第1天 正在运行的事务在服务器故障转移后继续执行
- 浅析SQL Server中包含事务的存储过程
- Mysql中的事务是什么如何使用
- MySql的事务使用与示例详解
- C#分布式事务的超时处理实例分析
- C#中的事务用法实例分析
- SQL Server的事务操作隔离模式介绍
- MySQL中事务概念的简洁学习教程
- C#处理Access中事务的方法
- oracle 合并查询 事务 sql函数小知识学习
- Hibernate Oracle sequence的使用技巧
- jsp Hibernate批量更新和批量删除处理代码
- jsp hibernate的分页代码第1/3页
- sql不常用函数总结以及事务,增加,删除触发器
- JAVA+Hibernate 无限级分类
- SSH整合中 hibernate托管给Spring得到SessionFactory
- jsp hibernate 数据保存操作的原理
- mysql的XA事务恢复过程详解
- 在Mysql存储过程中使用事务实例
- hibernate中的增删改查实现代码