
| Key: |
OPENJPA-177
|
| Type: |
Bug
|
| Status: |
Resolved
|
| Resolution: |
Fixed
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Daniel Gajdos
|
| Votes: |
0
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Windows XP, IBM 32-bit SDK 5.0, WebSphere 6.1
|
|
Issue Links:
|
Reference
|
|
This issue relates to:
|
|
OPENJPA-235
SQL reordering to avoid non-nullable foreign key constraint violations
|
|
|
|
|
|
|
|
| Resolution Date: |
31/Jul/07 07:53 PM
|
|
When using on entity Application
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "C_PERSON_ID", nullable=false)
@ForeignKey
private Person person;
and on entity Person using generated ID, it fails on inserting Application because of performing db actions in this order:
INSERT INTO T_APPLICATION (C_ID, C_APPLICATION_NUMBER, C_APPLIED_DATE, C_STATUS) VALUES (:1, :2, :3, :4) - here it tries to insert null value as C_PERSON_ID, which is not permited because of nullable=false declaration. This declaration creates NOT NULL constraint on C_PERSON_ID.
INSERT INTO NSVISP.T_PERSON (C_ID, C_BIRTH_DATE, C_FIRST_NAME, C_LAST_NAME) VALUES (:1, :2, :3, :4)
UPDATE NSVISP.T_APPLICATION SET C_PERSON_ID = :1 WHERE C_ID = :2
Error reported from DB:
org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01400: cannot insert NULL into ("T_APPLICATION"."C_PERSON_ID")
Is there any chance to change the order in which this operations are executed? On this type of constraint we have to insert Person before inserting Application and include the generated Person Id into insert statement for Application. Otherwise we have to deffer the NOT NULL constraint which can be dangerous and it is not defered initialy.
|
|
Description
|
When using on entity Application
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "C_PERSON_ID", nullable=false)
@ForeignKey
private Person person;
and on entity Person using generated ID, it fails on inserting Application because of performing db actions in this order:
INSERT INTO T_APPLICATION (C_ID, C_APPLICATION_NUMBER, C_APPLIED_DATE, C_STATUS) VALUES (:1, :2, :3, :4) - here it tries to insert null value as C_PERSON_ID, which is not permited because of nullable=false declaration. This declaration creates NOT NULL constraint on C_PERSON_ID.
INSERT INTO NSVISP.T_PERSON (C_ID, C_BIRTH_DATE, C_FIRST_NAME, C_LAST_NAME) VALUES (:1, :2, :3, :4)
UPDATE NSVISP.T_APPLICATION SET C_PERSON_ID = :1 WHERE C_ID = :2
Error reported from DB:
org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01400: cannot insert NULL into ("T_APPLICATION"."C_PERSON_ID")
Is there any chance to change the order in which this operations are executed? On this type of constraint we have to insert Person before inserting Application and include the generated Person Id into insert statement for Application. Otherwise we have to deffer the NOT NULL constraint which can be dangerous and it is not defered initialy. |
Show » |
made changes - 04/May/07 06:29 PM
| Field |
Original Value |
New Value |
|
Link
|
|
This issue relates to OPENJPA-235
[ OPENJPA-235
]
|
made changes - 31/Jul/07 07:53 PM
|
Resolution
|
|
Fixed
[ 1
]
|
|
Fix Version/s
|
|
1.0.0
[ 12312341
]
|
|
Status
|
Open
[ 1
]
|
Resolved
[ 5
]
|
|