{"action":"created","comment":{"url":"https://api.github.com/repos/javers/javers/pulls/comments/23208272","id":23208272,"diff_hunk":"@@ -0,0 +1,66 @@\n+package org.javers.repository.sql.domain;\n+\n+import org.javers.core.commit.CommitMetadata;\n+import org.javers.repository.sql.poly.JaversPolyJDBC;\n+import org.javers.repository.sql.schema.FixedSchemaFactory;\n+import org.joda.time.LocalDateTime;\n+import org.polyjdbc.core.query.InsertQuery;\n+import org.polyjdbc.core.query.SelectQuery;\n+import org.polyjdbc.core.query.mapper.ObjectMapper;\n+import org.polyjdbc.core.type.Timestamp;\n+\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+\n+import static org.javers.repository.sql.schema.FixedSchemaFactory.COMMIT_TABLE_AUTHOR;\n+\n+/**\n+ * @author pawel szymczyk\n+ */\n+public class CommitRepository {\n+\n+    private JaversPolyJDBC javersPolyjdbc;\n+\n+    public CommitRepository(JaversPolyJDBC javersPolyjdbc) {\n+        this.javersPolyjdbc = javersPolyjdbc;\n+    }\n+\n+    public long save(CommitMetadata commitMetadata) {\n+        Long primaryKey = findCommitMetadata(commitMetadata);\n+        \n+        return primaryKey != null ? primaryKey : insert(commitMetadata);\n+    }\n+\n+    private Long findCommitMetadata(CommitMetadata commitMetadata) {\n+        SelectQuery selectQuery = javersPolyjdbc.query()\n+                .select(FixedSchemaFactory.COMMIT_TABLE_PK)\n+                .from(FixedSchemaFactory.COMMIT_TABLE_NAME)","path":"javers-persistence-sql/src/main/java/org/javers/repository/sql/domain/CommitRepository.java","position":37,"original_position":37,"commit_id":"0cf5bc6c1205767e0238d983a75768b07f6eea00","original_commit_id":"0cf5bc6c1205767e0238d983a75768b07f6eea00","user":{"login":"bartoszwalacik","id":2511028,"avatar_url":"https://avatars.githubusercontent.com/u/2511028?v=3","gravatar_id":"","url":"https://api.github.com/users/bartoszwalacik","html_url":"https://github.com/bartoszwalacik","followers_url":"https://api.github.com/users/bartoszwalacik/followers","following_url":"https://api.github.com/users/bartoszwalacik/following{/other_user}","gists_url":"https://api.github.com/users/bartoszwalacik/gists{/gist_id}","starred_url":"https://api.github.com/users/bartoszwalacik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartoszwalacik/subscriptions","organizations_url":"https://api.github.com/users/bartoszwalacik/orgs","repos_url":"https://api.github.com/users/bartoszwalacik/repos","events_url":"https://api.github.com/users/bartoszwalacik/events{/privacy}","received_events_url":"https://api.github.com/users/bartoszwalacik/received_events","type":"User","site_admin":false},"body":"dodaj static import żeby wytrzeć FixedSchemaFactory.","created_at":"2015-01-20T08:34:32Z","updated_at":"2015-01-20T08:34:32Z","html_url":"https://github.com/javers/javers/pull/90#discussion_r23208272","pull_request_url":"https://api.github.com/repos/javers/javers/pulls/90","_links":{"self":{"href":"https://api.github.com/repos/javers/javers/pulls/comments/23208272"},"html":{"href":"https://github.com/javers/javers/pull/90#discussion_r23208272"},"pull_request":{"href":"https://api.github.com/repos/javers/javers/pulls/90"}}},"pull_request":{"url":"https://api.github.com/repos/javers/javers/pulls/90","id":27635556,"html_url":"https://github.com/javers/javers/pull/90","diff_url":"https://github.com/javers/javers/pull/90.diff","patch_url":"https://github.com/javers/javers/pull/90.patch","issue_url":"https://api.github.com/repos/javers/javers/issues/90","number":90,"state":"open","locked":false,"title":"#67 commit repo","user":{"login":"pawelszymczyk","id":6159409,"avatar_url":"https://avatars.githubusercontent.com/u/6159409?v=3","gravatar_id":"","url":"https://api.github.com/users/pawelszymczyk","html_url":"https://github.com/pawelszymczyk","followers_url":"https://api.github.com/users/pawelszymczyk/followers","following_url":"https://api.github.com/users/pawelszymczyk/following{/other_user}","gists_url":"https://api.github.com/users/pawelszymczyk/gists{/gist_id}","starred_url":"https://api.github.com/users/pawelszymczyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pawelszymczyk/subscriptions","organizations_url":"https://api.github.com/users/pawelszymczyk/orgs","repos_url":"https://api.github.com/users/pawelszymczyk/repos","events_url":"https://api.github.com/users/pawelszymczyk/events{/privacy}","received_events_url":"https://api.github.com/users/pawelszymczyk/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-19T21:04:02Z","updated_at":"2015-01-20T08:34:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"25d253d1eb33c5a4f1660d9c979582c4fe930319","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/javers/javers/pulls/90/commits","review_comments_url":"https://api.github.com/repos/javers/javers/pulls/90/comments","review_comment_url":"https://api.github.com/repos/javers/javers/pulls/comments/{number}","comments_url":"https://api.github.com/repos/javers/javers/issues/90/comments","statuses_url":"https://api.github.com/repos/javers/javers/statuses/0cf5bc6c1205767e0238d983a75768b07f6eea00","head":{"label":"javers:#67_commit_repo","ref":"#67_commit_repo","sha":"0cf5bc6c1205767e0238d983a75768b07f6eea00","user":{"login":"javers","id":6149633,"avatar_url":"https://avatars.githubusercontent.com/u/6149633?v=3","gravatar_id":"","url":"https://api.github.com/users/javers","html_url":"https://github.com/javers","followers_url":"https://api.github.com/users/javers/followers","following_url":"https://api.github.com/users/javers/following{/other_user}","gists_url":"https://api.github.com/users/javers/gists{/gist_id}","starred_url":"https://api.github.com/users/javers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javers/subscriptions","organizations_url":"https://api.github.com/users/javers/orgs","repos_url":"https://api.github.com/users/javers/repos","events_url":"https://api.github.com/users/javers/events{/privacy}","received_events_url":"https://api.github.com/users/javers/received_events","type":"Organization","site_admin":false},"repo":{"id":15071115,"name":"javers","full_name":"javers/javers","owner":{"login":"javers","id":6149633,"avatar_url":"https://avatars.githubusercontent.com/u/6149633?v=3","gravatar_id":"","url":"https://api.github.com/users/javers","html_url":"https://github.com/javers","followers_url":"https://api.github.com/users/javers/followers","following_url":"https://api.github.com/users/javers/following{/other_user}","gists_url":"https://api.github.com/users/javers/gists{/gist_id}","starred_url":"https://api.github.com/users/javers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javers/subscriptions","organizations_url":"https://api.github.com/users/javers/orgs","repos_url":"https://api.github.com/users/javers/repos","events_url":"https://api.github.com/users/javers/events{/privacy}","received_events_url":"https://api.github.com/users/javers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/javers/javers","description":"JaVers is a tool for auditing object-oriented data","fork":false,"url":"https://api.github.com/repos/javers/javers","forks_url":"https://api.github.com/repos/javers/javers/forks","keys_url":"https://api.github.com/repos/javers/javers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javers/javers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javers/javers/teams","hooks_url":"https://api.github.com/repos/javers/javers/hooks","issue_events_url":"https://api.github.com/repos/javers/javers/issues/events{/number}","events_url":"https://api.github.com/repos/javers/javers/events","assignees_url":"https://api.github.com/repos/javers/javers/assignees{/user}","branches_url":"https://api.github.com/repos/javers/javers/branches{/branch}","tags_url":"https://api.github.com/repos/javers/javers/tags","blobs_url":"https://api.github.com/repos/javers/javers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javers/javers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javers/javers/git/refs{/sha}","trees_url":"https://api.github.com/repos/javers/javers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javers/javers/statuses/{sha}","languages_url":"https://api.github.com/repos/javers/javers/languages","stargazers_url":"https://api.github.com/repos/javers/javers/stargazers","contributors_url":"https://api.github.com/repos/javers/javers/contributors","subscribers_url":"https://api.github.com/repos/javers/javers/subscribers","subscription_url":"https://api.github.com/repos/javers/javers/subscription","commits_url":"https://api.github.com/repos/javers/javers/commits{/sha}","git_commits_url":"https://api.github.com/repos/javers/javers/git/commits{/sha}","comments_url":"https://api.github.com/repos/javers/javers/comments{/number}","issue_comment_url":"https://api.github.com/repos/javers/javers/issues/comments/{number}","contents_url":"https://api.github.com/repos/javers/javers/contents/{+path}","compare_url":"https://api.github.com/repos/javers/javers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javers/javers/merges","archive_url":"https://api.github.com/repos/javers/javers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javers/javers/downloads","issues_url":"https://api.github.com/repos/javers/javers/issues{/number}","pulls_url":"https://api.github.com/repos/javers/javers/pulls{/number}","milestones_url":"https://api.github.com/repos/javers/javers/milestones{/number}","notifications_url":"https://api.github.com/repos/javers/javers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javers/javers/labels{/name}","releases_url":"https://api.github.com/repos/javers/javers/releases{/id}","created_at":"2013-12-10T08:23:03Z","updated_at":"2015-01-20T07:50:42Z","pushed_at":"2015-01-19T23:17:20Z","git_url":"git://github.com/javers/javers.git","ssh_url":"git@github.com:javers/javers.git","clone_url":"https://github.com/javers/javers.git","svn_url":"https://github.com/javers/javers","homepage":"","size":3536,"stargazers_count":43,"watchers_count":43,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":16,"forks":2,"open_issues":16,"watchers":43,"default_branch":"master"}},"base":{"label":"javers:#67_sql_repository","ref":"#67_sql_repository","sha":"de888033d8fc6073e79ea29d39752f65a898f88a","user":{"login":"javers","id":6149633,"avatar_url":"https://avatars.githubusercontent.com/u/6149633?v=3","gravatar_id":"","url":"https://api.github.com/users/javers","html_url":"https://github.com/javers","followers_url":"https://api.github.com/users/javers/followers","following_url":"https://api.github.com/users/javers/following{/other_user}","gists_url":"https://api.github.com/users/javers/gists{/gist_id}","starred_url":"https://api.github.com/users/javers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javers/subscriptions","organizations_url":"https://api.github.com/users/javers/orgs","repos_url":"https://api.github.com/users/javers/repos","events_url":"https://api.github.com/users/javers/events{/privacy}","received_events_url":"https://api.github.com/users/javers/received_events","type":"Organization","site_admin":false},"repo":{"id":15071115,"name":"javers","full_name":"javers/javers","owner":{"login":"javers","id":6149633,"avatar_url":"https://avatars.githubusercontent.com/u/6149633?v=3","gravatar_id":"","url":"https://api.github.com/users/javers","html_url":"https://github.com/javers","followers_url":"https://api.github.com/users/javers/followers","following_url":"https://api.github.com/users/javers/following{/other_user}","gists_url":"https://api.github.com/users/javers/gists{/gist_id}","starred_url":"https://api.github.com/users/javers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javers/subscriptions","organizations_url":"https://api.github.com/users/javers/orgs","repos_url":"https://api.github.com/users/javers/repos","events_url":"https://api.github.com/users/javers/events{/privacy}","received_events_url":"https://api.github.com/users/javers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/javers/javers","description":"JaVers is a tool for auditing object-oriented data","fork":false,"url":"https://api.github.com/repos/javers/javers","forks_url":"https://api.github.com/repos/javers/javers/forks","keys_url":"https://api.github.com/repos/javers/javers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javers/javers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javers/javers/teams","hooks_url":"https://api.github.com/repos/javers/javers/hooks","issue_events_url":"https://api.github.com/repos/javers/javers/issues/events{/number}","events_url":"https://api.github.com/repos/javers/javers/events","assignees_url":"https://api.github.com/repos/javers/javers/assignees{/user}","branches_url":"https://api.github.com/repos/javers/javers/branches{/branch}","tags_url":"https://api.github.com/repos/javers/javers/tags","blobs_url":"https://api.github.com/repos/javers/javers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javers/javers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javers/javers/git/refs{/sha}","trees_url":"https://api.github.com/repos/javers/javers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javers/javers/statuses/{sha}","languages_url":"https://api.github.com/repos/javers/javers/languages","stargazers_url":"https://api.github.com/repos/javers/javers/stargazers","contributors_url":"https://api.github.com/repos/javers/javers/contributors","subscribers_url":"https://api.github.com/repos/javers/javers/subscribers","subscription_url":"https://api.github.com/repos/javers/javers/subscription","commits_url":"https://api.github.com/repos/javers/javers/commits{/sha}","git_commits_url":"https://api.github.com/repos/javers/javers/git/commits{/sha}","comments_url":"https://api.github.com/repos/javers/javers/comments{/number}","issue_comment_url":"https://api.github.com/repos/javers/javers/issues/comments/{number}","contents_url":"https://api.github.com/repos/javers/javers/contents/{+path}","compare_url":"https://api.github.com/repos/javers/javers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javers/javers/merges","archive_url":"https://api.github.com/repos/javers/javers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javers/javers/downloads","issues_url":"https://api.github.com/repos/javers/javers/issues{/number}","pulls_url":"https://api.github.com/repos/javers/javers/pulls{/number}","milestones_url":"https://api.github.com/repos/javers/javers/milestones{/number}","notifications_url":"https://api.github.com/repos/javers/javers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javers/javers/labels{/name}","releases_url":"https://api.github.com/repos/javers/javers/releases{/id}","created_at":"2013-12-10T08:23:03Z","updated_at":"2015-01-20T07:50:42Z","pushed_at":"2015-01-19T23:17:20Z","git_url":"git://github.com/javers/javers.git","ssh_url":"git@github.com:javers/javers.git","clone_url":"https://github.com/javers/javers.git","svn_url":"https://github.com/javers/javers","homepage":"","size":3536,"stargazers_count":43,"watchers_count":43,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":16,"forks":2,"open_issues":16,"watchers":43,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/javers/javers/pulls/90"},"html":{"href":"https://github.com/javers/javers/pull/90"},"issue":{"href":"https://api.github.com/repos/javers/javers/issues/90"},"comments":{"href":"https://api.github.com/repos/javers/javers/issues/90/comments"},"review_comments":{"href":"https://api.github.com/repos/javers/javers/pulls/90/comments"},"review_comment":{"href":"https://api.github.com/repos/javers/javers/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/javers/javers/pulls/90/commits"},"statuses":{"href":"https://api.github.com/repos/javers/javers/statuses/0cf5bc6c1205767e0238d983a75768b07f6eea00"}}}}