我们正在尝试在 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:
慕田峪7331174
相关分类