Skip to main content

Bug in EntityService AddIndex

  2 posts   Feedicon  
Replies: 1 - Last Post: April 08, 2013 19:44
by: Ralph
« Older Topic » Newer Topic
showing 1 - 2 of 2
Posted: April 06, 2013 06:41 by AsgarSerran
I've found a bug in the entityservice in the addindex method.
If you have already created some workitems with additional read and write access defined in the model
and you add an index with the addindex method of the entityservice you will get foreign key constraint
errors like this:

Cannot delete or update a parent row: a foreign key constraint fails (`imixs_db_pool`.`entity_writeaccess`, CONSTRAINT `FK_ENTITY_WRITEACCESS_writeAccessList_ID` FOREIGN KEY (`writeAccessList_ID`) REFERENCES `writeaccess` (`ID`)) Error Code: 1451 Call: DELETE FROM WRITEACCESS WHERE (ID = ?) bind => [1 parameter bound] Query: DeleteObjectQuery(org.imixs.workflow.jee.jpa.WriteAccess@214f32ce)

The reason for that seems to be in the updateWriteAccessList method at line 0968. manager.remove(aItem);
The list will be cleared afterwards at line 0969. aEntity.getWriteAccessList().clear(); but there it seems to be to late.
The writeaccess is already removed before the reference in the entity_writeaccess table is removed so the exception is
thrown.
I then backuped the writeaccess and entity_writeaccess table and truncated them so I thought it should work but
it didn't the next exception was:

Cannot delete or update a parent row: a foreign key constraint fails (`imixs_db_pool`.`entity_textitem`, CONSTRAINT `FK_ENTITY_TEXTITEM_textItems_ID` FOREIGN KEY (`textItems_ID`) REFERENCES `textitem` (`ID`)) Error Code: 1451 Call: DELETE FROM TEXTITEM WHERE (ID = ?) bind => [1 parameter bound] Query: DeleteObjectQuery(org.imixs.workflow.jee.jpa.TextItem@1cac871e)

which I first couldn't understand, but then I got it, it tries to update all the entities and add the index,
so it creates the textitem for my new index and somehow it tries to deleteit here, don't know what
is going on maybe I don't understand the code of the EntityService enough.

A workaround which worked for me is to delete all Entities and then add the index, afterwards I back uped the entities.
The only problem with the soltion is, that the new index will be only applied for new entites which during development
shouldn't be a problem, but if you want to develop it further after a productive time it would be a real problem.

I hope I could help you finding this bug and reproducing it.
Posted: April 08, 2013 19:44 by Ralph
I added a bug into the issue tracker:
http://java.net/jira/browse/IMIXS_WORKFLOW-179

I hope I can reproduce this in a test scenario.

The addIndex() method is still a method which can be improved...
Replies: 1 - Last Post: April 08, 2013 19:44
by: Ralph
« Older Topic » Newer Topic
 
 
Close
loading
Please Confirm
Close