Unidirectional OneToMany insert NULL for foreign key and issue extra update SQL
(Doc ID 2512131.1)
Last updated on MARCH 16, 2021
Applies to:
Oracle TopLink - Version 12.2.1.1.0 and laterInformation in this document applies to any platform.
Symptoms
EclipseLink inserts entities with unidirectional one-to-many relationship using INSERT statement
followed by UPDATE statement which updates foreign keys in target table, if required. This may cause issues if foreign key has NOT NULL constraint, typically configurable using @JoinColumn(nullable=false)
Exaample:
[EL Fine]: 2018-03-28 16:48:56.328--Connection(2061337484)--INSERT INTO JPA_CUSTOMER (ID, CUSTOMER_NAME) VALUES (?, ?)
bind => [1000, Joey]
[EL Fine]: 2018-03-28 16:48:56.338--Connection(2061337484)--INSERT INTO JPA_ORDER (ORDER_ID, ORDER_ITEM) VALUES (?, ?)
[EL Fine]: 2018-03-28 16:48:56.339--Connection(2061337484)-- bind => [1001,spaghetti]
[EL Fine]: 2018-03-28 16:48:56.339--Connection(2061337484)-- bind => [1000,Pizza]
[EL Fine]: 2018-03-28 16:48:56.343--Connection(2061337484)--UPDATE JPA_ORDER
SET CUS_ID = ? WHERE (ORDER_ID = ?)
[EL Fine]: 2018-03-28 16:48:56.343--Connection(2061337484)-- bind => [1000,1000]
[EL Fine]: 2018-03-28 16:48:56.343--Connection(2061337484)-- bind => [1000,1001]
Changes
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Changes |
Cause |
Solution |
References |