{"action":"created","comment":{"url":"https://api.github.com/repos/NitorCreations/nflow/pulls/comments/58267546","id":58267546,"diff_hunk":"@@ -167,27 +171,32 @@ private int insertWorkflowInstanceWithTransaction(final WorkflowInstance instanc\n       @Override\n       public Integer doInTransaction(TransactionStatus status) {\n         KeyHolder keyHolder = new GeneratedKeyHolder();\n-        jdbc.update(new PreparedStatementCreator() {\n-          @Override\n-          @SuppressFBWarnings(value = \"OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE\", justification = \"findbugs does not trust jdbctemplate\")\n-          public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {\n-            PreparedStatement ps;\n-            int p = 1;\n-            ps = connection.prepareStatement(insertWorkflowInstanceSql(), new String[] { \"id\" });\n-            ps.setString(p++, instance.type);\n-            ps.setObject(p++, instance.rootWorkflowId);\n-            ps.setObject(p++, instance.parentWorkflowId);\n-            ps.setObject(p++, instance.parentActionId);\n-            ps.setString(p++, instance.businessKey);\n-            ps.setString(p++, instance.externalId);\n-            ps.setString(p++, executorInfo.getExecutorGroup());\n-            ps.setString(p++, instance.status.name());\n-            ps.setString(p++, instance.state);\n-            ps.setString(p++, abbreviate(instance.stateText, instanceStateTextLength));\n-            ps.setTimestamp(p++, toTimestamp(instance.nextActivation));\n-            return ps;\n-          }\n-        }, keyHolder);\n+        try {\n+          jdbc.update(new PreparedStatementCreator() {\n+            @Override\n+            @SuppressFBWarnings(value = \"OBL_UNSATISFIED_OBLIGATION_EXCEPTION_EDGE\", justification = \"findbugs does not trust jdbctemplate\")\n+            public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {\n+              PreparedStatement ps;\n+              int p = 1;\n+              ps = connection.prepareStatement(insertWorkflowInstanceSql(), new String[] { \"id\" });\n+              ps.setString(p++, instance.type);\n+              ps.setObject(p++, instance.rootWorkflowId);\n+              ps.setObject(p++, instance.parentWorkflowId);\n+              ps.setObject(p++, instance.parentActionId);\n+              ps.setString(p++, instance.businessKey);\n+              ps.setString(p++, instance.externalId);\n+              ps.setString(p++, executorInfo.getExecutorGroup());\n+              ps.setString(p++, instance.status.name());\n+              ps.setString(p++, instance.state);\n+              ps.setString(p++, abbreviate(instance.stateText, instanceStateTextLength));\n+              ps.setTimestamp(p++, toTimestamp(instance.nextActivation));\n+              return ps;\n+            }\n+          }, keyHolder);\n+        } catch (DuplicateKeyException e) {\n+          logger.warn(\"Failed to insert workflow instance\", e);\n+          return -1;\n+        }\n         int id = keyHolder.getKey().intValue();","path":"nflow-engine/src/main/java/com/nitorcreations/nflow/engine/internal/dao/WorkflowInstanceDao.java","position":132,"original_position":132,"commit_id":"e9cc4a229746fb1c035d9f9edaaf27f23614f455","original_commit_id":"e9cc4a229746fb1c035d9f9edaaf27f23614f455","user":{"login":"jsyrjala","id":25238,"avatar_url":"https://avatars.githubusercontent.com/u/25238?v=3","gravatar_id":"","url":"https://api.github.com/users/jsyrjala","html_url":"https://github.com/jsyrjala","followers_url":"https://api.github.com/users/jsyrjala/followers","following_url":"https://api.github.com/users/jsyrjala/following{/other_user}","gists_url":"https://api.github.com/users/jsyrjala/gists{/gist_id}","starred_url":"https://api.github.com/users/jsyrjala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsyrjala/subscriptions","organizations_url":"https://api.github.com/users/jsyrjala/orgs","repos_url":"https://api.github.com/users/jsyrjala/repos","events_url":"https://api.github.com/users/jsyrjala/events{/privacy}","received_events_url":"https://api.github.com/users/jsyrjala/received_events","type":"User","site_admin":false},"body":"If it gets DuplicateKeyException above, this will insert variables again? => there will be double set of variables?\r\n\r\nIs the end result same as with insertWorkflowInstanceWithCte() ?\r\n\r\nWould it be better to not modify variables in case of duplicate key exception?","created_at":"2016-04-01T21:06:13Z","updated_at":"2016-04-01T21:06:13Z","html_url":"https://github.com/NitorCreations/nflow/pull/188#discussion_r58267546","pull_request_url":"https://api.github.com/repos/NitorCreations/nflow/pulls/188","_links":{"self":{"href":"https://api.github.com/repos/NitorCreations/nflow/pulls/comments/58267546"},"html":{"href":"https://github.com/NitorCreations/nflow/pull/188#discussion_r58267546"},"pull_request":{"href":"https://api.github.com/repos/NitorCreations/nflow/pulls/188"}}},"pull_request":{"url":"https://api.github.com/repos/NitorCreations/nflow/pulls/188","id":64965951,"html_url":"https://github.com/NitorCreations/nflow/pull/188","diff_url":"https://github.com/NitorCreations/nflow/pull/188.diff","patch_url":"https://github.com/NitorCreations/nflow/pull/188.patch","issue_url":"https://api.github.com/repos/NitorCreations/nflow/issues/188","number":188,"state":"open","locked":false,"title":"do not rollback transaction when inserting workflow instance that already exists","user":{"login":"efonsell","id":1535478,"avatar_url":"https://avatars.githubusercontent.com/u/1535478?v=3","gravatar_id":"","url":"https://api.github.com/users/efonsell","html_url":"https://github.com/efonsell","followers_url":"https://api.github.com/users/efonsell/followers","following_url":"https://api.github.com/users/efonsell/following{/other_user}","gists_url":"https://api.github.com/users/efonsell/gists{/gist_id}","starred_url":"https://api.github.com/users/efonsell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/efonsell/subscriptions","organizations_url":"https://api.github.com/users/efonsell/orgs","repos_url":"https://api.github.com/users/efonsell/repos","events_url":"https://api.github.com/users/efonsell/events{/privacy}","received_events_url":"https://api.github.com/users/efonsell/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-01T15:54:57Z","updated_at":"2016-04-01T21:06:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b71bd8088dec1cc8c74af18c30ade0c771b25d49","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/NitorCreations/nflow/pulls/188/commits","review_comments_url":"https://api.github.com/repos/NitorCreations/nflow/pulls/188/comments","review_comment_url":"https://api.github.com/repos/NitorCreations/nflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/NitorCreations/nflow/issues/188/comments","statuses_url":"https://api.github.com/repos/NitorCreations/nflow/statuses/e9cc4a229746fb1c035d9f9edaaf27f23614f455","head":{"label":"NitorCreations:create-workflow-fix","ref":"create-workflow-fix","sha":"e9cc4a229746fb1c035d9f9edaaf27f23614f455","user":{"login":"NitorCreations","id":1389534,"avatar_url":"https://avatars.githubusercontent.com/u/1389534?v=3","gravatar_id":"","url":"https://api.github.com/users/NitorCreations","html_url":"https://github.com/NitorCreations","followers_url":"https://api.github.com/users/NitorCreations/followers","following_url":"https://api.github.com/users/NitorCreations/following{/other_user}","gists_url":"https://api.github.com/users/NitorCreations/gists{/gist_id}","starred_url":"https://api.github.com/users/NitorCreations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NitorCreations/subscriptions","organizations_url":"https://api.github.com/users/NitorCreations/orgs","repos_url":"https://api.github.com/users/NitorCreations/repos","events_url":"https://api.github.com/users/NitorCreations/events{/privacy}","received_events_url":"https://api.github.com/users/NitorCreations/received_events","type":"Organization","site_admin":false},"repo":{"id":16453755,"name":"nflow","full_name":"NitorCreations/nflow","owner":{"login":"NitorCreations","id":1389534,"avatar_url":"https://avatars.githubusercontent.com/u/1389534?v=3","gravatar_id":"","url":"https://api.github.com/users/NitorCreations","html_url":"https://github.com/NitorCreations","followers_url":"https://api.github.com/users/NitorCreations/followers","following_url":"https://api.github.com/users/NitorCreations/following{/other_user}","gists_url":"https://api.github.com/users/NitorCreations/gists{/gist_id}","starred_url":"https://api.github.com/users/NitorCreations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NitorCreations/subscriptions","organizations_url":"https://api.github.com/users/NitorCreations/orgs","repos_url":"https://api.github.com/users/NitorCreations/repos","events_url":"https://api.github.com/users/NitorCreations/events{/privacy}","received_events_url":"https://api.github.com/users/NitorCreations/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NitorCreations/nflow","description":"nFlow is a light-weight and modular solution for orchestrating processes using Java. It can be used for orchestrating microservices, as traditional business process engine or as asynchronous backend dispatcher.","fork":false,"url":"https://api.github.com/repos/NitorCreations/nflow","forks_url":"https://api.github.com/repos/NitorCreations/nflow/forks","keys_url":"https://api.github.com/repos/NitorCreations/nflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NitorCreations/nflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NitorCreations/nflow/teams","hooks_url":"https://api.github.com/repos/NitorCreations/nflow/hooks","issue_events_url":"https://api.github.com/repos/NitorCreations/nflow/issues/events{/number}","events_url":"https://api.github.com/repos/NitorCreations/nflow/events","assignees_url":"https://api.github.com/repos/NitorCreations/nflow/assignees{/user}","branches_url":"https://api.github.com/repos/NitorCreations/nflow/branches{/branch}","tags_url":"https://api.github.com/repos/NitorCreations/nflow/tags","blobs_url":"https://api.github.com/repos/NitorCreations/nflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NitorCreations/nflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NitorCreations/nflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/NitorCreations/nflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NitorCreations/nflow/statuses/{sha}","languages_url":"https://api.github.com/repos/NitorCreations/nflow/languages","stargazers_url":"https://api.github.com/repos/NitorCreations/nflow/stargazers","contributors_url":"https://api.github.com/repos/NitorCreations/nflow/contributors","subscribers_url":"https://api.github.com/repos/NitorCreations/nflow/subscribers","subscription_url":"https://api.github.com/repos/NitorCreations/nflow/subscription","commits_url":"https://api.github.com/repos/NitorCreations/nflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/NitorCreations/nflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/NitorCreations/nflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/NitorCreations/nflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/NitorCreations/nflow/contents/{+path}","compare_url":"https://api.github.com/repos/NitorCreations/nflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NitorCreations/nflow/merges","archive_url":"https://api.github.com/repos/NitorCreations/nflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NitorCreations/nflow/downloads","issues_url":"https://api.github.com/repos/NitorCreations/nflow/issues{/number}","pulls_url":"https://api.github.com/repos/NitorCreations/nflow/pulls{/number}","milestones_url":"https://api.github.com/repos/NitorCreations/nflow/milestones{/number}","notifications_url":"https://api.github.com/repos/NitorCreations/nflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NitorCreations/nflow/labels{/name}","releases_url":"https://api.github.com/repos/NitorCreations/nflow/releases{/id}","deployments_url":"https://api.github.com/repos/NitorCreations/nflow/deployments","created_at":"2014-02-02T11:56:18Z","updated_at":"2016-01-21T11:52:27Z","pushed_at":"2016-04-01T15:54:58Z","git_url":"git://github.com/NitorCreations/nflow.git","ssh_url":"git@github.com:NitorCreations/nflow.git","clone_url":"https://github.com/NitorCreations/nflow.git","svn_url":"https://github.com/NitorCreations/nflow","homepage":"","size":5073,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":8,"default_branch":"master"}},"base":{"label":"NitorCreations:master","ref":"master","sha":"8bf26bea38f21f4ada36662c30df18c723ca0637","user":{"login":"NitorCreations","id":1389534,"avatar_url":"https://avatars.githubusercontent.com/u/1389534?v=3","gravatar_id":"","url":"https://api.github.com/users/NitorCreations","html_url":"https://github.com/NitorCreations","followers_url":"https://api.github.com/users/NitorCreations/followers","following_url":"https://api.github.com/users/NitorCreations/following{/other_user}","gists_url":"https://api.github.com/users/NitorCreations/gists{/gist_id}","starred_url":"https://api.github.com/users/NitorCreations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NitorCreations/subscriptions","organizations_url":"https://api.github.com/users/NitorCreations/orgs","repos_url":"https://api.github.com/users/NitorCreations/repos","events_url":"https://api.github.com/users/NitorCreations/events{/privacy}","received_events_url":"https://api.github.com/users/NitorCreations/received_events","type":"Organization","site_admin":false},"repo":{"id":16453755,"name":"nflow","full_name":"NitorCreations/nflow","owner":{"login":"NitorCreations","id":1389534,"avatar_url":"https://avatars.githubusercontent.com/u/1389534?v=3","gravatar_id":"","url":"https://api.github.com/users/NitorCreations","html_url":"https://github.com/NitorCreations","followers_url":"https://api.github.com/users/NitorCreations/followers","following_url":"https://api.github.com/users/NitorCreations/following{/other_user}","gists_url":"https://api.github.com/users/NitorCreations/gists{/gist_id}","starred_url":"https://api.github.com/users/NitorCreations/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NitorCreations/subscriptions","organizations_url":"https://api.github.com/users/NitorCreations/orgs","repos_url":"https://api.github.com/users/NitorCreations/repos","events_url":"https://api.github.com/users/NitorCreations/events{/privacy}","received_events_url":"https://api.github.com/users/NitorCreations/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/NitorCreations/nflow","description":"nFlow is a light-weight and modular solution for orchestrating processes using Java. It can be used for orchestrating microservices, as traditional business process engine or as asynchronous backend dispatcher.","fork":false,"url":"https://api.github.com/repos/NitorCreations/nflow","forks_url":"https://api.github.com/repos/NitorCreations/nflow/forks","keys_url":"https://api.github.com/repos/NitorCreations/nflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NitorCreations/nflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NitorCreations/nflow/teams","hooks_url":"https://api.github.com/repos/NitorCreations/nflow/hooks","issue_events_url":"https://api.github.com/repos/NitorCreations/nflow/issues/events{/number}","events_url":"https://api.github.com/repos/NitorCreations/nflow/events","assignees_url":"https://api.github.com/repos/NitorCreations/nflow/assignees{/user}","branches_url":"https://api.github.com/repos/NitorCreations/nflow/branches{/branch}","tags_url":"https://api.github.com/repos/NitorCreations/nflow/tags","blobs_url":"https://api.github.com/repos/NitorCreations/nflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NitorCreations/nflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NitorCreations/nflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/NitorCreations/nflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NitorCreations/nflow/statuses/{sha}","languages_url":"https://api.github.com/repos/NitorCreations/nflow/languages","stargazers_url":"https://api.github.com/repos/NitorCreations/nflow/stargazers","contributors_url":"https://api.github.com/repos/NitorCreations/nflow/contributors","subscribers_url":"https://api.github.com/repos/NitorCreations/nflow/subscribers","subscription_url":"https://api.github.com/repos/NitorCreations/nflow/subscription","commits_url":"https://api.github.com/repos/NitorCreations/nflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/NitorCreations/nflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/NitorCreations/nflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/NitorCreations/nflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/NitorCreations/nflow/contents/{+path}","compare_url":"https://api.github.com/repos/NitorCreations/nflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NitorCreations/nflow/merges","archive_url":"https://api.github.com/repos/NitorCreations/nflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NitorCreations/nflow/downloads","issues_url":"https://api.github.com/repos/NitorCreations/nflow/issues{/number}","pulls_url":"https://api.github.com/repos/NitorCreations/nflow/pulls{/number}","milestones_url":"https://api.github.com/repos/NitorCreations/nflow/milestones{/number}","notifications_url":"https://api.github.com/repos/NitorCreations/nflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NitorCreations/nflow/labels{/name}","releases_url":"https://api.github.com/repos/NitorCreations/nflow/releases{/id}","deployments_url":"https://api.github.com/repos/NitorCreations/nflow/deployments","created_at":"2014-02-02T11:56:18Z","updated_at":"2016-01-21T11:52:27Z","pushed_at":"2016-04-01T15:54:58Z","git_url":"git://github.com/NitorCreations/nflow.git","ssh_url":"git@github.com:NitorCreations/nflow.git","clone_url":"https://github.com/NitorCreations/nflow.git","svn_url":"https://github.com/NitorCreations/nflow","homepage":"","size":5073,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":3,"forks":7,"open_issues":3,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/NitorCreations/nflow/pulls/188"},"html":{"href":"https://github.com/NitorCreations/nflow/pull/188"},"issue":{"href":"https://api.github.com/repos/NitorCreations/nflow/issues/188"},"comments":{"href":"https://api.github.com/repos/NitorCreations/nflow/issues/188/comments"},"review_comments":{"href":"https://api.github.com/repos/NitorCreations/nflow/pulls/188/comments"},"review_comment":{"href":"https://api.github.com/repos/NitorCreations/nflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/NitorCreations/nflow/pulls/188/commits"},"statuses":{"href":"https://api.github.com/repos/NitorCreations/nflow/statuses/e9cc4a229746fb1c035d9f9edaaf27f23614f455"}}}}