{"action":"created","comment":{"url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/comments/26208039","id":26208039,"diff_hunk":"@@ -0,0 +1,129 @@\n+/*\n+ * Hibernate OGM, Domain model persistence for NoSQL datastores\n+ *\n+ * License: GNU Lesser General Public License (LGPL), version 2.1 or later\n+ * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.\n+ */\n+package org.hibernate.ogm.transaction.impl;\n+\n+import org.hibernate.HibernateException;\n+import org.hibernate.TransactionException;\n+import org.hibernate.engine.transaction.internal.jdbc.JdbcIsolationDelegate;\n+import org.hibernate.engine.transaction.spi.AbstractTransactionImpl;\n+import org.hibernate.engine.transaction.spi.IsolationDelegate;\n+import org.hibernate.engine.transaction.spi.JoinStatus;\n+import org.hibernate.engine.transaction.spi.LocalStatus;\n+import org.hibernate.engine.transaction.spi.TransactionCoordinator;\n+import org.hibernate.ogm.util.impl.Log;\n+import org.hibernate.ogm.util.impl.LoggerFactory;\n+\n+/**\n+ * A emulated transaction whose only purpose it is to make sure that on commit the appropriate flush events gets triggered.\n+ *\n+ * @author Hardy Ferentschik\n+ */\n+public class EmulatedLocalTransaction extends AbstractTransactionImpl {\n+\tprivate static final Log log = LoggerFactory.make();\n+\n+\tprivate boolean isDriver;\n+\n+\tprotected EmulatedLocalTransaction(TransactionCoordinator transactionCoordinator) {\n+\t\tsuper( transactionCoordinator );\n+\t}\n+\n+\t@Override\n+\tprotected void doBegin() {\n+\t\tisDriver = transactionCoordinator().takeOwnership();\n+\t}\n+\n+\t@Override\n+\tprotected void afterTransactionBegin() {\n+\t\ttransactionCoordinator().sendAfterTransactionBeginNotifications( this );\n+\t\tif ( isDriver ) {\n+\t\t\ttransactionCoordinator().getTransactionContext().afterTransactionBegin( this );\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tprotected void beforeTransactionCommit() {\n+\t\ttransactionCoordinator().sendBeforeTransactionCompletionNotifications( this );\n+\n+\t\t// basically, if we are the driver of the transaction perform a managed flush prior to\n+\t\t// physically committing the transaction\n+\t\tif ( isDriver && !transactionCoordinator().getTransactionContext().isFlushModeNever() ) {\n+\t\t\t// if an exception occurs during flush, user must call rollback()\n+\t\t\ttransactionCoordinator().getTransactionContext().managedFlush();\n+\t\t}\n+\n+\t\tif ( isDriver ) {\n+\t\t\ttransactionCoordinator().getTransactionContext().beforeTransactionCompletion( this );\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tprotected void doCommit() throws TransactionException {\n+\t}\n+\n+\t@Override\n+\tprotected void afterTransactionCompletion(int status) {\n+\t\ttransactionCoordinator().afterTransaction( this, status );\n+\t}\n+\n+\t@Override\n+\tprotected void afterAfterCompletion() {\n+\t\tif ( isDriver\n+\t\t\t\t&& transactionCoordinator().getTransactionContext().shouldAutoClose()\n+\t\t\t\t&& !transactionCoordinator().getTransactionContext().isClosed() ) {\n+\t\t\ttry {\n+\t\t\t\ttransactionCoordinator().getTransactionContext().managedClose();\n+\t\t\t}\n+\t\t\tcatch ( HibernateException e ) {\n+\t\t\t\tlog.unableToCloseSessionButSwallowingError( e );\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tprotected void beforeTransactionRollBack() {\n+\t\t// nothing to do here\n+\t}\n+\n+\t@Override\n+\tprotected void doRollback() throws TransactionException {\n+\t}\n+\n+\t@Override\n+\tpublic boolean isInitiator() {\n+\t\treturn isActive();","path":"core/src/main/java/org/hibernate/ogm/transaction/impl/EmulatedLocalTransaction.java","position":97,"original_position":97,"commit_id":"8b267310c0001e3832a8e7ab6e6ce6be2788c7eb","original_commit_id":"8b267310c0001e3832a8e7ab6e6ce6be2788c7eb","user":{"login":"hferentschik","id":296354,"avatar_url":"https://avatars.githubusercontent.com/u/296354?v=3","gravatar_id":"","url":"https://api.github.com/users/hferentschik","html_url":"https://github.com/hferentschik","followers_url":"https://api.github.com/users/hferentschik/followers","following_url":"https://api.github.com/users/hferentschik/following{/other_user}","gists_url":"https://api.github.com/users/hferentschik/gists{/gist_id}","starred_url":"https://api.github.com/users/hferentschik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hferentschik/subscriptions","organizations_url":"https://api.github.com/users/hferentschik/orgs","repos_url":"https://api.github.com/users/hferentschik/repos","events_url":"https://api.github.com/users/hferentschik/events{/privacy}","received_events_url":"https://api.github.com/users/hferentschik/received_events","type":"User","site_admin":false},"body":"this is from the JDBC transaction code. I guess always returning true might work as well. I have to strong feeling for either solution.","created_at":"2015-03-11T12:37:39Z","updated_at":"2015-03-11T12:37:39Z","html_url":"https://github.com/hibernate/hibernate-ogm/pull/504#discussion_r26208039","pull_request_url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504","_links":{"self":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/comments/26208039"},"html":{"href":"https://github.com/hibernate/hibernate-ogm/pull/504#discussion_r26208039"},"pull_request":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504"}}},"pull_request":{"url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504","id":30653064,"html_url":"https://github.com/hibernate/hibernate-ogm/pull/504","diff_url":"https://github.com/hibernate/hibernate-ogm/pull/504.diff","patch_url":"https://github.com/hibernate/hibernate-ogm/pull/504.patch","issue_url":"https://api.github.com/repos/hibernate/hibernate-ogm/issues/504","number":504,"state":"open","locked":false,"title":"OGM-718 Make sure RESOURCE_LOCAL persistence unit do not require a transaction manager","user":{"login":"hferentschik","id":296354,"avatar_url":"https://avatars.githubusercontent.com/u/296354?v=3","gravatar_id":"","url":"https://api.github.com/users/hferentschik","html_url":"https://github.com/hferentschik","followers_url":"https://api.github.com/users/hferentschik/followers","following_url":"https://api.github.com/users/hferentschik/following{/other_user}","gists_url":"https://api.github.com/users/hferentschik/gists{/gist_id}","starred_url":"https://api.github.com/users/hferentschik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hferentschik/subscriptions","organizations_url":"https://api.github.com/users/hferentschik/orgs","repos_url":"https://api.github.com/users/hferentschik/repos","events_url":"https://api.github.com/users/hferentschik/events{/privacy}","received_events_url":"https://api.github.com/users/hferentschik/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-06T15:29:57Z","updated_at":"2015-03-11T12:37:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6eafb7ae309e31924515c2123cd6d7fb194a005","assignee":{"login":"gunnarmorling","id":28612,"avatar_url":"https://avatars.githubusercontent.com/u/28612?v=3","gravatar_id":"","url":"https://api.github.com/users/gunnarmorling","html_url":"https://github.com/gunnarmorling","followers_url":"https://api.github.com/users/gunnarmorling/followers","following_url":"https://api.github.com/users/gunnarmorling/following{/other_user}","gists_url":"https://api.github.com/users/gunnarmorling/gists{/gist_id}","starred_url":"https://api.github.com/users/gunnarmorling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gunnarmorling/subscriptions","organizations_url":"https://api.github.com/users/gunnarmorling/orgs","repos_url":"https://api.github.com/users/gunnarmorling/repos","events_url":"https://api.github.com/users/gunnarmorling/events{/privacy}","received_events_url":"https://api.github.com/users/gunnarmorling/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504/commits","review_comments_url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504/comments","review_comment_url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hibernate/hibernate-ogm/issues/504/comments","statuses_url":"https://api.github.com/repos/hibernate/hibernate-ogm/statuses/8b267310c0001e3832a8e7ab6e6ce6be2788c7eb","head":{"label":"hferentschik:OGM-718-II","ref":"OGM-718-II","sha":"8b267310c0001e3832a8e7ab6e6ce6be2788c7eb","user":{"login":"hferentschik","id":296354,"avatar_url":"https://avatars.githubusercontent.com/u/296354?v=3","gravatar_id":"","url":"https://api.github.com/users/hferentschik","html_url":"https://github.com/hferentschik","followers_url":"https://api.github.com/users/hferentschik/followers","following_url":"https://api.github.com/users/hferentschik/following{/other_user}","gists_url":"https://api.github.com/users/hferentschik/gists{/gist_id}","starred_url":"https://api.github.com/users/hferentschik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hferentschik/subscriptions","organizations_url":"https://api.github.com/users/hferentschik/orgs","repos_url":"https://api.github.com/users/hferentschik/repos","events_url":"https://api.github.com/users/hferentschik/events{/privacy}","received_events_url":"https://api.github.com/users/hferentschik/received_events","type":"User","site_admin":false},"repo":{"id":27828474,"name":"hibernate-ogm","full_name":"hferentschik/hibernate-ogm","owner":{"login":"hferentschik","id":296354,"avatar_url":"https://avatars.githubusercontent.com/u/296354?v=3","gravatar_id":"","url":"https://api.github.com/users/hferentschik","html_url":"https://github.com/hferentschik","followers_url":"https://api.github.com/users/hferentschik/followers","following_url":"https://api.github.com/users/hferentschik/following{/other_user}","gists_url":"https://api.github.com/users/hferentschik/gists{/gist_id}","starred_url":"https://api.github.com/users/hferentschik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hferentschik/subscriptions","organizations_url":"https://api.github.com/users/hferentschik/orgs","repos_url":"https://api.github.com/users/hferentschik/repos","events_url":"https://api.github.com/users/hferentschik/events{/privacy}","received_events_url":"https://api.github.com/users/hferentschik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hferentschik/hibernate-ogm","description":"Hibernate Object/Grid Mapper","fork":true,"url":"https://api.github.com/repos/hferentschik/hibernate-ogm","forks_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/forks","keys_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/teams","hooks_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/hooks","issue_events_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/issues/events{/number}","events_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/events","assignees_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/assignees{/user}","branches_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/branches{/branch}","tags_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/tags","blobs_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/git/refs{/sha}","trees_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/statuses/{sha}","languages_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/languages","stargazers_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/stargazers","contributors_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/contributors","subscribers_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/subscribers","subscription_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/subscription","commits_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/commits{/sha}","git_commits_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/git/commits{/sha}","comments_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/comments{/number}","issue_comment_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/issues/comments{/number}","contents_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/contents/{+path}","compare_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/merges","archive_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/downloads","issues_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/issues{/number}","pulls_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/pulls{/number}","milestones_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/milestones{/number}","notifications_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/labels{/name}","releases_url":"https://api.github.com/repos/hferentschik/hibernate-ogm/releases{/id}","created_at":"2014-12-10T16:26:51Z","updated_at":"2014-12-10T16:26:53Z","pushed_at":"2015-03-10T22:36:23Z","git_url":"git://github.com/hferentschik/hibernate-ogm.git","ssh_url":"git@github.com:hferentschik/hibernate-ogm.git","clone_url":"https://github.com/hferentschik/hibernate-ogm.git","svn_url":"https://github.com/hferentschik/hibernate-ogm","homepage":"http://hibernate.org/ogm/","size":10472,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hibernate:master","ref":"master","sha":"515ad23a5b6516771169cf84691fa3aae9a97ac4","user":{"login":"hibernate","id":348262,"avatar_url":"https://avatars.githubusercontent.com/u/348262?v=3","gravatar_id":"","url":"https://api.github.com/users/hibernate","html_url":"https://github.com/hibernate","followers_url":"https://api.github.com/users/hibernate/followers","following_url":"https://api.github.com/users/hibernate/following{/other_user}","gists_url":"https://api.github.com/users/hibernate/gists{/gist_id}","starred_url":"https://api.github.com/users/hibernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hibernate/subscriptions","organizations_url":"https://api.github.com/users/hibernate/orgs","repos_url":"https://api.github.com/users/hibernate/repos","events_url":"https://api.github.com/users/hibernate/events{/privacy}","received_events_url":"https://api.github.com/users/hibernate/received_events","type":"Organization","site_admin":false},"repo":{"id":1608936,"name":"hibernate-ogm","full_name":"hibernate/hibernate-ogm","owner":{"login":"hibernate","id":348262,"avatar_url":"https://avatars.githubusercontent.com/u/348262?v=3","gravatar_id":"","url":"https://api.github.com/users/hibernate","html_url":"https://github.com/hibernate","followers_url":"https://api.github.com/users/hibernate/followers","following_url":"https://api.github.com/users/hibernate/following{/other_user}","gists_url":"https://api.github.com/users/hibernate/gists{/gist_id}","starred_url":"https://api.github.com/users/hibernate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hibernate/subscriptions","organizations_url":"https://api.github.com/users/hibernate/orgs","repos_url":"https://api.github.com/users/hibernate/repos","events_url":"https://api.github.com/users/hibernate/events{/privacy}","received_events_url":"https://api.github.com/users/hibernate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hibernate/hibernate-ogm","description":"Hibernate Object/Grid Mapper","fork":false,"url":"https://api.github.com/repos/hibernate/hibernate-ogm","forks_url":"https://api.github.com/repos/hibernate/hibernate-ogm/forks","keys_url":"https://api.github.com/repos/hibernate/hibernate-ogm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hibernate/hibernate-ogm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hibernate/hibernate-ogm/teams","hooks_url":"https://api.github.com/repos/hibernate/hibernate-ogm/hooks","issue_events_url":"https://api.github.com/repos/hibernate/hibernate-ogm/issues/events{/number}","events_url":"https://api.github.com/repos/hibernate/hibernate-ogm/events","assignees_url":"https://api.github.com/repos/hibernate/hibernate-ogm/assignees{/user}","branches_url":"https://api.github.com/repos/hibernate/hibernate-ogm/branches{/branch}","tags_url":"https://api.github.com/repos/hibernate/hibernate-ogm/tags","blobs_url":"https://api.github.com/repos/hibernate/hibernate-ogm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hibernate/hibernate-ogm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hibernate/hibernate-ogm/git/refs{/sha}","trees_url":"https://api.github.com/repos/hibernate/hibernate-ogm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hibernate/hibernate-ogm/statuses/{sha}","languages_url":"https://api.github.com/repos/hibernate/hibernate-ogm/languages","stargazers_url":"https://api.github.com/repos/hibernate/hibernate-ogm/stargazers","contributors_url":"https://api.github.com/repos/hibernate/hibernate-ogm/contributors","subscribers_url":"https://api.github.com/repos/hibernate/hibernate-ogm/subscribers","subscription_url":"https://api.github.com/repos/hibernate/hibernate-ogm/subscription","commits_url":"https://api.github.com/repos/hibernate/hibernate-ogm/commits{/sha}","git_commits_url":"https://api.github.com/repos/hibernate/hibernate-ogm/git/commits{/sha}","comments_url":"https://api.github.com/repos/hibernate/hibernate-ogm/comments{/number}","issue_comment_url":"https://api.github.com/repos/hibernate/hibernate-ogm/issues/comments{/number}","contents_url":"https://api.github.com/repos/hibernate/hibernate-ogm/contents/{+path}","compare_url":"https://api.github.com/repos/hibernate/hibernate-ogm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hibernate/hibernate-ogm/merges","archive_url":"https://api.github.com/repos/hibernate/hibernate-ogm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hibernate/hibernate-ogm/downloads","issues_url":"https://api.github.com/repos/hibernate/hibernate-ogm/issues{/number}","pulls_url":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls{/number}","milestones_url":"https://api.github.com/repos/hibernate/hibernate-ogm/milestones{/number}","notifications_url":"https://api.github.com/repos/hibernate/hibernate-ogm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hibernate/hibernate-ogm/labels{/name}","releases_url":"https://api.github.com/repos/hibernate/hibernate-ogm/releases{/id}","created_at":"2011-04-13T11:40:56Z","updated_at":"2015-03-10T23:19:01Z","pushed_at":"2015-03-11T11:34:26Z","git_url":"git://github.com/hibernate/hibernate-ogm.git","ssh_url":"git@github.com:hibernate/hibernate-ogm.git","clone_url":"https://github.com/hibernate/hibernate-ogm.git","svn_url":"https://github.com/hibernate/hibernate-ogm","homepage":"http://hibernate.org/ogm/","size":18108,"stargazers_count":147,"watchers_count":147,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":107,"mirror_url":null,"open_issues_count":2,"forks":107,"open_issues":2,"watchers":147,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504"},"html":{"href":"https://github.com/hibernate/hibernate-ogm/pull/504"},"issue":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/issues/504"},"comments":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/issues/504/comments"},"review_comments":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504/comments"},"review_comment":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/pulls/504/commits"},"statuses":{"href":"https://api.github.com/repos/hibernate/hibernate-ogm/statuses/8b267310c0001e3832a8e7ab6e6ce6be2788c7eb"}}}}