亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Hibernate 正在拋出托管刷新異常

Hibernate 正在拋出托管刷新異常

狐的傳說 2023-06-04 17:51:10
我們正在嘗試在 Oracle 中保存實體:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0我們同樣使用Hibernate :我們收到以下明顯錯誤:o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement]詳細的相關堆棧跟蹤如下:[ERROR]--- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-00001: unique constraint (XXX.PK_USER_FAVORITE) violated  [WARN ]  --- [nio-8080-exec-9] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1, SQLState: 23000  [ERROR] --- [nio-8080-exec-9] o.h.i.ExceptionMapperStandardImpl : HHH000346: Error during managed flush [**org.hibernate.exception.ConstraintViolationException**: could not execute statement] [ERROR] --- [nio-8080-exec-9] c.mastercard.refarch.aop.ServiceLogging : {"aop_service":"UserFavoritesService", "method":"addCurrentUserFavorite", "type":"failed", "error":"could not execute statement; SQL [n/a]; constraint [XXX.PK_USER_FAVORITE]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement", "args":"(["s029158",{"userFavoriteId":null,"applicationId":"XXX","functionAlphaCode":"SOME vale","title":"Service Report"}])"}我們正在使用oracle 序列來生成主鍵值。我想當 oracle 序列試圖執行時我們遇到了上述問題。每當我們遇到上述異常時,Hibernate 都無法執行 Oracle 序列,這是這里的主要問題。我們試圖保存在數據庫上的實體也沒有空值和主鍵約束。當前 Hibernate 版本是Hibernate-core 5.2.17 ,如果 hibernate JPA 是Hibernate-JPA-2.1-API-1.0.2.Final 則版本仍然想知道為什么我們得到:托管刷新期間出錯 [org.hibernate.exception.ConstraintViolationException:
查看完整描述

1 回答

?
慕田峪7331174

TA貢獻1828條經驗 獲得超13個贊

重要的部分是錯誤消息,它說ORA-00001: unique constraint (XXX.PK_USER_FAVORITE) violated。顯然違反了您的 USER_FAVORITE 表的唯一約束。

檢查序列以查看其下一個值是什么,然后檢查 USER_FAVORITE 表中此唯一鍵列的最大值是多少。如果唯一列的最大值 >= 序列中的下一個值,則您必須解決問題。


查看完整回答
反對 回復 2023-06-04
  • 1 回答
  • 0 關注
  • 253 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號