-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
AS 4.2.2.GA
-
None
I got a problem with updating the relation table between two entities.
This problem only occurs when i'm using a "Listener" class to set a field from a MappedSuperclass.
I have a GeneralEntity as MappedSuperclass with one attribute and two entities which inherit this field from the GeneralEntity. Additional the Parent and Child have one idFeld which is tagged as Identifier and one dataField from type String. Between Parent and child we have a M:N relation.
When i send an update to the database with a parent object including a child object, the persist method is called and data is saved correctly in the database.
When i send an update again (with or without changes) and using the same identifiers, then is no update on parent table, no update on child table, which is correct when nothing is changed, BUT we have an delete on the relation table!!
I check the server log and found the following part, where the delete statement is triggered:
2007-12-13 16:47:23,546 DEBUG [org.hibernate.SQL] delete from PARENTS2CHILD where PARENTS_ID_FELD1_FK=? and CHILD_ID_FELD2_FK=?
For a second test i add the annotation @persistence.column.update to the systemId attribute in the MappedSuperclass. So the system should ignore this field when updating.
When i call the update method the first time. All data is inserted correctly to the database.
When i call the update method the second time to change the dataFields i got an unique constraint error from the database, because the system is trying to make a insert on the relation table!! This is not possible because the necessary entry is existing yet.
The server log looks similar to the server log above, but instead of the delete statement we have an insert statement.
It's a bit of a strange problem, because this only happens when using a listener and setting a field from a MappedSuperclass in there and having a M:N relation or a relation which produces a relation table in the database.
Do i something wrong or is this maybe a bug?
Can someone give me a hint?
Thanks
Roland (Darquerus)