Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01400: cannot insert NULL

550287Dec 6 2006 — edited Jan 29 2007
JDeveloper 10.1.3.1.0 final release.

I am having an extremely frustrating problem inserting a new record. I have set this up with several different tables already and they worked fine. The difference with this table is that is contains a composite key.

I have the following two tables.

create table HARDWARE_MANUFACTURER (
MANUFACTURER_ID NUMBER not null,
ACTIVE CHAR(1),
constraint PK_HARDWARE_MANUFACTURER primary key (MANUFACTURER_ID)
);

create table HARDWARE_MODEL (
MODEL_ID NUMBER not null,
MANUFACTURER_ID NUMBER not null,
MODEL_DESCRIPTION VARCHAR2(100),
ACTIVE CHAR(1),
constraint PK_HARDWARE_MODEL primary key (MANUFACTURER_ID, MODEL_ID)
);

When the entity is persisted (I click save) I get the error message below.
You will notice that in the SQL the field MANUFACTURER_ID is null, however where I debug the method and look at the value of that field inside the "entity" parameter, it does actually contain the correct value for this field... so "persist" is being called with a correct object, but is generating the wrong SQL.

public Object persistEntity(Object entity) {
em.persist(entity); //breakpoint here, column value is ok
return entity;
}

Error Message received:

oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: ORA-01400: cannot insert NULL into ("AT"."HARDWARE_MODEL"."MANUFACTURER_ID")
Error Code: 1400 Call:INSERT INTO HARDWARE_MODEL (MODEL_ID, MODEL_DESCRIPTION, ACTIVE, MANUFACTURER_ID) VALUES (?, ?, ?, ?) bind => [10, test, null, null]

Any help would be most appreciated.

~R
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2007
Added on Dec 6 2006
3 comments
1,088 views