Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Bizarre constraint violation

I’m dealing with EJB 3.1 SSBs which inject a JTA PersistenceContext.  In one of them is a method which is annotated to require a new transaction. Inside that method the code looks up an entity of type Request, then it deletes an entity of type Foo, and then it attempts to create a new entity of type Foo. In the process of creating this new entity of type Foo it performs a named typed query against an entity of Type Bar (eg. SELECT b FROM Bar WHERE b.name=:name).  When the code calls query.getResultSet() and exception is thrown which references a constraint violation on an entity of type Request. Specifically:

java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (MYDB.REQUEST_FILE_NUMBER) violated - child record found.

From the stack trace its being triggered by the entity manager performing a pre query flush.  The constraint involved is for referential integrity between a Request and a File. The Request object has an optional 1-to-1 unidirectional relationship with File and the constraint is there to ensure the referenced file exists. In this case the Request has a null value for the its File property which should be OK given this is an optional relationship.  A Request is not being merged or persisted it was simply looked up at the start of the TX. 

I’m baffled as to why this is being thrown.  Any thoughts are appreciated. 

Thanks,

-Noah



Back to the top