Attempting to alter the same filter field value ends up with an error such as:
Caused by: org.mariadb.jdbc.internal.common.QueryException: Duplicate entry 'topicIds-92' for key 'index3'
Attempting to remove the old field and add a new one, throws the following error:
15:55:40,059 ERROR [org.hibernate.AssertionFailure] (http-/0.0.0.0:8180-1) HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.HibernateException: Could not determine type of dynamic map entity
The problem looks to be the order that hibernate executes the statements. It will always do inserts before deletes, see:
Looks like you can't make MySQL/MariaDB do deferred constraint checks either (see http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html).
As such we'll likely need to reorder how REST updates are done so that delete statements are done, flushed and then the rest of the content is inserted/updated.
Fixed in 1.9-SNAPSHOT build 201407291548
The core way rest entities were synced with database entities has been re-written so that it is done in stages based on the required action. This allows us to do the deletes first, flush the changes and then do the create/update operations. As such the way it works now is:
1. Collect any change information.
2. Perform the deletions on the children entities, if there are any.
3. Flush the deletions.
4. Create any new entities, syncing only the base information.
5. Update any information and perform the additional sync processing (ie XML formatting)
Note: This version has been deployed to the development/test server.
Note 2: These changes haven't been merged with devel and are currently in the BZ#1116705 branch.
Created a filter, populated all the fields, saved it, loaded it again, edited or deleted all the field and saved again ok.
I also tested adding and removing values and relationships in entities like topics, content specs, images, files, property tags, property tag categories, tags, projects and categories. There were two bugs that I found. They are probably not related to this, but I'll list there here anyway:
In any case the original bug is verified.
*** Bug 1124577 has been marked as a duplicate of this bug. ***
Moving back to ASSIGNED because of BZ#1124577
*** Bug 1124578 has been marked as a duplicate of this bug. ***
Fixed the above two issues in 1.9-SNAPSHOT build 201407300910 since they were caused by this change.
Note: This version is currently live on the test/development server.
Verified that I can now add and remove tags from categories without any errors.
Merged the changes into the devel branch.