posted 10 years ago
Hi everybody,
I hope for some assistance regarding an issue with a cascading update action in my application. The application uses Apache OpenJPA 2.0.1. There is a problem with the data model consisting of three entities.
I have an entity called hotel, having zero to many rooms and zero to many infos. A room can also have zero to many infos.
The table INFO consists (simplified) of a column for a generated id, a column for the id of a hotel, if the info belongs to a hotel. Also there is a column for a room id if the info belongs to a room and the info itself. A data set always consists of a hotel id and info OR room id and info.
The model looks like this
For reading access everything is working fine. When it comes to writing everything gets weird. I hoped to make changes in the infoList of a hotel or room object (add or remove entries) and OpenJPA manages to write the data in the db. But here starts the trouble.
In the configuration above I get the following error:
My guess is, that in the case of storing a hotel the room column is null, which is not allowed by the database. I tried generating a ‘dummy’ object with new Room() which ends in an error of a detached object.
I appreciate every idea what is wrong in my configuration.
Thanks a lot. Best regards.
Jochen