【发布时间】:2015-03-11 16:14:41
【问题描述】:
正如我在这篇帖子 JPA SET IDENTITY_INSERT not working 中提到的,我成功使用了
SET IDENTITY_INSERT
为我的目的查询。但是今天在我设法配置连接池之后,我遇到了这种类型的错误。
java.sql.SQLException: IDENTITY_INSERT is already ON for table 'mydb.dbo.[table1]'. Cannot perform SET operation for table 'dbo.[table2]'.
2015-03-11 15:52:36,126 WARN org.hibernate.util.JDBCExceptionReporter.logExceptions:233 - SQL Error: 544, SQLState: 23000
2015-03-11 15:52:36,127 ERROR org.hibernate.util.JDBCExceptionReporter.logExceptions:234 - Cannot insert explicit value for identity column in table '[table2]' when IDENTITY_INSERT is set to OFF.
2015-03-11 15:52:36,128 ERROR org.hibernate.event.def.AbstractFlushingEventListener.performExecutions:324 - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
任何人都可以提出解决此错误的建议吗?
【问题讨论】:
标签: java sql-server hibernate jpa