解决客户端 query did not return aunique result:2
来源:互联网 发布:备案域名交易平台top 编辑:程序博客网 时间:2024/06/11 01:08
解决客户端 query did not return aunique result:2
从字面意思很好理解,查询出了两条相同的记录,说明数据库出现了脏数据,反复检验程序并未发现有bug。
最终 确定 是由于 程序是布在 两个节点上。当同一用户发出两次相同的请求时,执行的两次保存数据的动作 ,被分别分配在了两台节点服务上边,导致了脏数据的产生。
解决办法: 系统架构是用的是 hibernate。则使用框架自带 的乐观锁 来 保证 事务的 完整性
乐观锁的工作原理:读取出数据时,将此版本号一同读出,之后更新时,对此版本号加一。此时,将提交数据的版本数据与数据库表对应记录的当前版本信息进行比对,如果提交的数据版本号大于数据库表当前版本号,则予以更新,否则认为是过期数据
@Entity@Table(name = "customer")@ApiModelpublic class Customer extends BaseEntity { @Version @Column(nullable = false) private Long version;
阅读全文
0 0
- 解决客户端 query did not return aunique result:2
- NonUniqueResultException: query did not return a unique result: 2
- query did not return a unique result: 2
- query did not return a unique result
- query did not return a unique result: 275
- query did not return a unique result: 3 错误
- org.hibernate.NonUniqueResultException: query did not return a unique result: 2
- org.hibernate.NonUniqueResultException: query did not return a unique result: 2
- org.hibernate.NonUniqueResultException: query did not return a unique result: 2
- query did not return a unique result (直译:查询没有返回一个唯一的结果)
- org.hibernate.NonUniqueResultException: query did not return a unique result: 3
- 【项目经验】org.hibernate.NonUniqueResultException: query did not return a unique result: 3
- oa系统里面用的jbpm报org.hibernate.NonUniqueResultException: query did not return a unique result: 4
- SQLServerException: The statement did not return a result set
- SQL Server set nocount on 与JDBC: The statement did not return a result
- java使用jdbc调用hive出现The query did not generate a result set!
- The provider did not return a ProviderManifestToken string
- MySQL CodeFirst "The provider did not return a ProviderManifestToken string."
- VueJs 监听 window.resize 方法---窗口变化
- WAP_WSP的Well-known header
- 优雅的QSignleton (一) Singleton单例实现
- MySQL学习(二)【MySQL数据库对象与应用】
- sigaction-sigqueue
- 解决客户端 query did not return aunique result:2
- 树莓派硬件PWM输出程序
- 隐语义模型
- SOA中springmvc中restful服务的数据权限加密方式分享
- GridLayoutManager画分割块,同时不影响item内容的宽高
- C# 正则表达式 使用介绍
- 学习笔记TF060:图像语音结合,看图说话
- 在SSH框架中,使用Spring设置定时器Quartz来开启定时任务
- cocos-lua学习笔记(三)引擎目录介绍