Search code examples
hsqldb

What does the HsqlException "integrity constraint violation: foreign key no parent" mean?


I am getting this error in my HSQLDB :

Caused by: org.hsqldb.HsqlException: integrity constraint violation: foreign key no parent; FK9GHQNBKBDJIGL1LN1V9DVN06O table: REVINFO

I initially thought it means that I was adding a null value to the column, however the key references a column (EDITORID) that is NULLABLE, so null values can be inserted.

I assume it is trying to add a value that does not yet exist in the referencing table, which I guess would make sense. However the exception does not tell me what actual value i am trying to insert.


Solution

  • updated: You were trying to insert a row with a value in the referencing column but there is no row with matching value in the referenced column. I checked the source code and although the actual value is added to the list of items to report, it is omitted when the error string is constructed. Therefore you need to rely on your code to report the value when you catch the SQLException until version 2.4.2 of HSQLDB enhances the reporting.