我试图通过应用程序在表中插入一些值,并得到ORA-00001:违反唯一约束的问题。我发现序列与表的最高id不同步,但即使在修复序列号之后,错误仍然存在。如何更多地调试此错误,oracle日志是否会给出更多错误?如何查看oracle日志?谢谢Priyank
更新:我们使用审计日志插件,并在User的域类中捕获save事件并将该条目记录到审计日志中
因此,在User类中,我们这样做:
class User {
//some attributes, constraints, mappings
def onSave = {
Graaudit aInstance = new Graaudit();
aInstance.eventType= "GRA User Create"
aInstance.eventDescription = "GRA User Created"
aInstance.objectid = username
aInstance.objecttype = 'GRAUSER'
aInstance.user_id = RequestContextHolder.currentRequestAttributes().session.username
aInstance.withTransaction{
aInstance.save()
}
}
}当我们在onSave事件中没有上面的代码时,用户就创建成功了。
我假设它与我们在aInstance上使用的hibernate事务有关,那就是死亡或当前事务由于保存而死亡。
如果我们不使用事务,我们会得到一个异常"org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here",不确定如何解决这个问题..谢谢
发布于 2012-03-14 02:00:38
错误消息将包括被违反的约束的名称(表上可能有多个唯一约束)。可以使用该约束名称来标识在其上声明唯一约束的列
SELECT column_name, position
FROM all_cons_columns
WHERE constraint_name = <<name of constraint from the error message>>
AND owner = <<owner of the table>>
AND table_name = <<name of the table>>一旦知道哪些列受到影响,就可以将尝试INSERT或UPDATE的数据与表中已有的数据进行比较,以确定违反约束的原因。
发布于 2013-07-28 02:41:51
发生此ORA错误是因为违反了唯一约束。
ORA-00001: unique constraint (constraint_name) violated这是因为尝试执行的INSERT或UPDATE语句在由唯一索引限制的字段中创建了重复值。
您可以通过以下方式解决此问题:
。
发布于 2012-03-14 02:01:07
Oracle的错误消息应该更长一些。它通常看起来像这样:
ORA-00001: unique constraint (TABLE_UK1) violated括号中的名称是约束名称。它会告诉您违反了哪个约束。
https://stackoverflow.com/questions/9689412
复制相似问题