13 Replies Latest reply on Jan 22, 2008 2:30 AM by dleerob

    problem while deleting processInstance

      Hi,

      I am trying to delete a processIntance using GrapSession object. What I have looks like

      GraphSession session = context.getGraphSession();
      ProcessInstance processInstance = null;
      if (session != null) {
      processInstance = session.getProcessInstance(processInstanceId);
      if (processInstance != null) {
      session.deleteProcessInstance(processInstance);
      }
      }

      When I do this i get a hibernate exception.


      org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Could not execute JDBC batch update; SQL [delete from JBPM_MODULEINSTANCE where ID_=?]; Cannot delete or update a parent row: a foreign key constraint fails (`forms/jbpm_swimlaneinstance`, CONSTRAINT `FK_SWIMLANEINST_TM` FOREIGN KEY (`TASKMGMTINSTANCE_`) REFERENCES `jbpm_moduleinstance` (`ID_`)); nested exception is java.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (`forms/jbpm_swimlaneinstance`, CONSTRAINT `FK_SWIMLANEINST_TM` FOREIGN KEY (`TASKMGMTINSTANCE_`) REFERENCES `jbpm_moduleinstance` (`ID_`))
      java.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (`forms/jbpm_swimlaneinstance`, CONSTRAINT `FK_SWIMLANEINST_TM` FOREIGN KEY (`TASKMGMTINSTANCE_`) REFERENCES `jbpm_moduleinstance` (`ID_`))

      am I missing something?

      thanks

        • 1. Re: problem while deleting processInstance

          Anyone has any ideas? I gotta fix this!

          • 3. Re: problem while deleting processInstance

            Thanks for your response. I did search the forum and googled around. I also so the open issues on the bug tracking system. Though issues seem to be related, they are not the same issues. People seems to be having problems with deleting sub processes. My set up does not include sub processes. I also realized some one suggested that I change database keys. I was happening to fix it without touching the database set up.

            • 4. Re: problem while deleting processInstance

              I don't have time to dig into it, but I'd guess that you're using too low an object to do the delete. I'd try to find a process instance delete method at a higher level that deletes swimlanes first.

              This is just a guess!

              -Ed Staub

              • 5. Re: problem while deleting processInstance

                After digging more, I'm starting to wonder if you might have a bug.
                If you're not running on HSQL, I'd wonder if it's db-dependent. Also, what version of JBPM?

                • 6. Re: problem while deleting processInstance

                  We are on version 3.1.2. The database is Mysql version 5.0.27. I thought it may have been related to MySql and have cascade deletes are handled. I still need to do some investigation on that. If you have any idea, I'd love to hear them. Thanks for your time.

                  • 7. Re: problem while deleting processInstance

                    Is it possible to delete swimlane instances via process instance?

                    • 8. Re: problem while deleting processInstance
                      kukeltje

                      VIA the processinstance? explain in more detail what you want

                      • 9. Re: problem while deleting processInstance

                        As someone suggested earlier on this thread, I was trying to figure out a way to delete all associated swimlane instances before deleting a given process instance. I have looked around the API but did not find a method that would help me delete swimlane instances. I was just wondering if there is a way to delete swimlane instances.

                        • 10. Re: problem while deleting processInstance

                          I have been doing some log analysis regarding this foreign key error. According to hibernate logs, swimlanes instances are deleted long before module instance is being deleted (as expected). However, it seems that not all swimlanes instances are deleted (at least for for my case). In the case that I have been working with I realized hibernate logged 5 delete statements.

                          299627 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,338 org.hibernate.jdbc.AbstractBatcher:logOpenPreparedStatement[311] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
                          299627 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,338 org.hibernate.jdbc.AbstractBatcher:log[346] delete from JBPM_SWIMLANEINSTANCE where ID_=?
                          299628 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,339 org.hibernate.jdbc.AbstractBatcher:prepareBatchStatement[175] reusing prepared statement
                          299628 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,339 org.hibernate.jdbc.AbstractBatcher:log[346] delete from JBPM_SWIMLANEINSTANCE where ID_=?
                          299629 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,340 org.hibernate.jdbc.AbstractBatcher:prepareBatchStatement[175] reusing prepared statement
                          299629 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,340 org.hibernate.jdbc.AbstractBatcher:log[346] delete from JBPM_SWIMLANEINSTANCE where ID_=?
                          299629 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,340 org.hibernate.jdbc.AbstractBatcher:prepareBatchStatement[175] reusing prepared statement
                          299630 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,341 org.hibernate.jdbc.AbstractBatcher:log[346] delete from JBPM_SWIMLANEINSTANCE where ID_=?
                          299630 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,341 org.hibernate.jdbc.AbstractBatcher:prepareBatchStatement[175] reusing prepared statement
                          299631 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,342 org.hibernate.jdbc.AbstractBatcher:log[346] delete from JBPM_SWIMLANEINSTANCE where ID_=?
                          299631 [http-8080-Processor22] DEBUG 2007-08-23 11:26:49,342 org.hibernate.jdbc.BatchingBatcher:doExecuteBatch[55] Executing batch size: 5

                          However, there were total of 6 swimlane instances in the jbpm_swimlaneinstance table (for the test case).

                          +-----+-----------------------+------------------------------+-----------+-------------------+
                          | ID_ | NAME_ | ACTORID_ | SWIMLANE_ | TASKMGMTINSTANCE_ |
                          +-----+-----------------------+------------------------------+-----------+-------------------+
                          | 38 | originator | xx@xx.com | 440 | 33 |
                          | 39 | charge code approvers | xx@xx.com | 441 | 33 |
                          | 40 | quality | xx@xx.com | 444 | 33 |
                          | 41 | procurement lead | xx@xx.com | 439 | 33 |
                          | 49 | charge code approvers | xx@xx.com | 441 | 33 |
                          | 50 | buyer | xx@xx.com | 442 | 33 |
                          +-----+-----------------------+------------------------------+-----------+-------------------+

                          JBPM then tried to delete module instance which basically threw the exception in question.

                          I think I need to figure out why that swimlane instance is not deleted. If you have any recommendations or ideas. Please let me know.

                          thanks

                          • 11. Re: problem while deleting processInstance

                            I just discovered that swimlane instances that are not being deleted are of same type of a swimlane. My set up allows for multiple swimlanes instances of a given swimlane to exist within a process instance. However, jbpm/hibernate seems to be getting only one instance of a swimlane.

                            The hbm files confirm that swimlane instance and swimlane have many to one relationship.

                            I am still trying to figure out why they are not being loaded for deletion.

                            • 12. Re: problem while deleting processInstance
                              kukeltje

                              'a way' is via HQL

                              • 13. Re: problem while deleting processInstance
                                dleerob

                                I am having the same problem. Some of my process instances can't be deleted, and I get that same exception. I can't even delete the whole process definition, as it fails when trying to delete the process instance.
                                Others seem to delete fine though.

                                Did you manage to sort out this problem? And if so, how?

                                Thanks for your time in this.