简体   繁体   English

Hibernate和ORA-01400:无法插入NULL

[英]Hibernate and ORA-01400: cannot insert NULL

I've got fairly simple scenario, one table, one sequence for auto-generating primary keys : 我有一个相当简单的场景,一个表,一个用于自动生成主键的序列:

CREATE TABLE foo (event_id NUMBER(19,0)....
CREATE SEQUENCE event_seq

Part of the hibernate mapping looks like this: 部分hibernate映射如下所示:

...
<id name="id" column="EVENT_ID" type="long">
   <generator class="native">
      <param name="sequence">event_seq</param>
   </generator>
</id>
...

Works well without a problem for a long time. 很长一段时间没有问题,运作良好。 But recently I've got this : 但最近我得到了这个:

ORA-01400: cannot insert NULL into ("TESTING"."FOO"."EVENT_ID")

Would that mean that Oracle failed to generate the sequence number for the EVENT_ID? 这是否意味着Oracle无法生成EVENT_ID的序列号? What could be a reason for this ? 这可能是什么原因 Apparently this error came from 64bit Oracle, could it be related to a problem? 显然这个错误来自64位Oracle,它可能与问题有关吗? Dropping and recreating the table and sequence doesn't help, it just doesn't want to work on that particular machine. 删除和重新创建表和序列没有帮助,它只是不想在该特定机器上工作。 No matter what I do, I can't reproduce this, the error comes from one of the users which is pretty much unreachable. 无论我做什么,我都无法重现这个,错误来自其中一个几乎无法访问的用户。

Any ideas? 有任何想法吗?

--------------- Problem solved --------------- - - - - - - - - 问题解决了 - - - - - - - -

The original issue was detected with Oracle 10.2.0.1.0 64bit while using driver 10.2.0.1.0 on 32bit OS. 在32位操作系统上使用驱动程序10.2.0.1.0时,使用Oracle 10.2.0.1.0 64位检测到原始问题。 Once the driver was updated to 11.2.0.2.0, the problem disappeared. 一旦驱动程序更新到11.2.0.2.0,问题就消失了。 It all depends on the VM's if they are running as 32bit or 64bit system. 如果它们运行的​​是32位或64位系统,这一切都取决于VM。

Oracle doesn't automatically generate sequence numbers on table inserts. Oracle不会自动在表插入上生成序列号。 You either have to code it into the insert, code it into a trigger or have hibernate do it. 您要么必须将其编码到插入中,将其编码为触发器​​,要么进行休眠操作。

I think hibernate needs <generator class="sequence"> if you want it to do it or your hibernate setup has stopped thinking you are dealing with an Oracle database 我认为hibernate需要<generator class="sequence">如果你想要它或你的hibernate设置已经停止认为你正在处理Oracle数据库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IntegrityError:ORA-01400:无法将NULL插入 - IntegrityError: ORA-01400: cannot insert NULL into INSERT失败,出现ORA-01400:无法插入NULL - INSERT fails with ORA-01400: cannot insert NULL oci_execute():ORA-01400:无法插入NULL - oci_execute(): ORA-01400: cannot insert NULL oracle.jdbc.OracleDatabaseException: ORA-01400: 不能插入 NULL - oracle.jdbc.OracleDatabaseException: ORA-01400: cannot insert NULL into ORA-01400 无法在一对一关系中插入 null 错误 - ORA-01400 cannot insert null error in one to one relationship Oracle-错误:&#39;ORA-01400:无法将NULL插入 - Oracle - Error: 'ORA-01400: cannot insert NULL into 当没有NULL值时,Oracle中出现错误“ ORA-01400:无法将NULL插入…” - Getting error in Oracle “ORA-01400: cannot insert NULL into…” when there are no NULL values Spring 启动错误 ORA-01400:无法将 NULL 插入(“AAKASH”.“USERS”.“EMAILVERIFICATIONSTATUS”) - Spring boot error ORA-01400: cannot insert NULL into (“AAKASH”.“USERS”.“EMAILVERIFICATIONSTATUS”) PL / SQL ORA-01400:使用CASE时无法将NULL插入 - PL/SQL ORA-01400: cannot insert NULL into when using CASE 警告:oci_execute():ORA-01400:无法插入NULL值 - Warning: oci_execute(): ORA-01400: cannot insert NULL value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM