TOPLINK-4002 error when persisting child entity using EJB 3 (Doc ID 727080.1)

Last updated on JULY 05, 2016

Applies to:

Oracle TopLink - Version 10.1.3.1 to 10.1.3.5 [Release AS10gR3]
Information in this document applies to any platform.
***Checked for relevance on 14-May-2013***

Symptoms

Trying to develop a sample application to persist an entity using EJB 3.0 the customer gets the following errors when executing persistentity method

1. JBO-29000: An exception occurred during transaction completion: ; nested exception is: javax.transaction.RollbackException: returning error in transaction: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: ORA-01400: cannot insert NULL into("SRDEMO"."CC_CDI"."COD_EMP") Error Code: 1400 Call: INSERT INTO CC_CDI (COD_CC, DT_CAD, COD_ATIVO, DT_UPD, USR_CAD, USR_UPD, DESC_CC, COD_EMP) VALUES (?, ?, ?, ?, ?, ?, ?, ?) bind => [1111, 2008-06-10 00:00:00.0, 1, 2008-06-03 00:00:00.0, americo, americo, 1, null] Query: InsertObjectQuery(br.com.unimedserv.apcdi.datamodel.CcCdi@ea7211)
2. An exception occurred during transaction completion: ; nested exception is: javax.transaction.RollbackException: returning error in transaction: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: ORA-01400: cannot insert NULL into ("SRDEMO"."CC_CDI"."COD_EMP") Error Code: 1400 Call: INSERT INTO CC_CDI (COD_CC, DT_CAD, COD_ATIVO, DT_UPD, USR_CAD, USR_UPD, DESC_CC, COD_EMP) VALUES (?, ?, ?, ?, ?, ?, ?, ?) bind => [1111, 2008-06-10 00:00:00.0, 1, 2008-06-03 00:00:00.0, americo, americo, 1, null] Query: InsertObjectQuery(br.com.unimedserv.apcdi.datamodel.CcCdi@ea7211)


The model is very simple and it consists of two tables:
- Table 1 (Many) has a composite key (pk1, pk2).
- Table 2 (One) has a simple primary key pk3 that matches pk1 from the first table.

When generating EJBs from the tables and try to persist an entity (using the constructor method to create form on a jspx page) representing a row in Table 1 an error occurs and states that a null value can´t be inserted.

This value corresponds to pk1 and it is set to null even though a correct value has been submitted in the jspx page.


Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms