Support gwtorm 1.2

In 1.2 gwtorm requires accessor @Query methods to be unique
names within the interface. This means the arguments must not be
overloaded, and required fixing up a few interfaces that relied on
method overloading to select the right query statement.

1.2 also requires a unique id number for each relation in the
schema interface, similar to how earlier versions have a unique
column number in each entity. These can be used by NoSQL based
systems for unique identity, specially the protobuf backend that
exists to support the NoSQL backends of gwtorm.

Change-Id: I19421b966e336ee0e89e6743d79e989860d8c470
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetDetailFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetDetailFactory.java
index f478d66..78f4ded 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetDetailFactory.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetDetailFactory.java
@@ -128,7 +128,7 @@
       byKey.put(p.getKey(), p);
     }
 
-    for (final PatchLineComment c : db.patchComments().published(psIdNew)) {
+    for (final PatchLineComment c : db.patchComments().publishedByPatchSet(psIdNew)) {
       final Patch p = byKey.get(c.getKey().getParentKey());
       if (p != null) {
         p.setCommentCount(p.getCommentCount() + 1);
@@ -148,7 +148,7 @@
       // quickly locate where they have pending drafts, and review them.
       //
       final Account.Id me = ((IdentifiedUser) user).getAccountId();
-      for (final PatchLineComment c : db.patchComments().draft(psIdNew, me)) {
+      for (final PatchLineComment c : db.patchComments().draftByPatchSetAuthor(psIdNew, me)) {
         final Patch p = byKey.get(c.getKey().getParentKey());
         if (p != null) {
           p.setDraftCount(p.getDraftCount() + 1);
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetPublishDetailFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetPublishDetailFactory.java
index cbddad1..8ec1549 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetPublishDetailFactory.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/PatchSetPublishDetailFactory.java
@@ -84,7 +84,7 @@
     final ChangeControl control = changeControlFactory.validateFor(changeId);
     change = control.getChange();
     patchSetInfo = infoFactory.get(patchSetId);
-    drafts = db.patchComments().draft(patchSetId, user.getAccountId()).toList();
+    drafts = db.patchComments().draftByPatchSetAuthor(patchSetId, user.getAccountId()).toList();
 
     aic.want(change.getOwner());
 
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java
index 9ad8e3a..5a60623 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/patch/PatchScriptFactory.java
@@ -287,7 +287,7 @@
 
   private void loadPublished(final Map<Patch.Key, Patch> byKey,
       final AccountInfoCacheFactory aic, final String file) throws OrmException {
-    for (PatchLineComment c : db.patchComments().published(changeId, file)) {
+    for (PatchLineComment c : db.patchComments().publishedByChangeFile(changeId, file)) {
       if (comments.include(c)) {
         aic.want(c.getAuthor());
       }
@@ -303,7 +303,7 @@
   private void loadDrafts(final Map<Patch.Key, Patch> byKey,
       final AccountInfoCacheFactory aic, final Account.Id me, final String file)
       throws OrmException {
-    for (PatchLineComment c : db.patchComments().draft(changeId, file, me)) {
+    for (PatchLineComment c : db.patchComments().draftByChangeFileAuthor(changeId, file, me)) {
       if (comments.include(c)) {
         aic.want(me);
       }
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/PatchLineCommentAccess.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/PatchLineCommentAccess.java
index 26785a8..ddff0f1 100644
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/PatchLineCommentAccess.java
+++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/PatchLineCommentAccess.java
@@ -30,35 +30,39 @@
 
   @Query("WHERE key.patchKey = ? AND status = '"
       + PatchLineComment.STATUS_PUBLISHED + "' ORDER BY lineNbr,writtenOn")
-  ResultSet<PatchLineComment> published(Patch.Key patch) throws OrmException;
+  ResultSet<PatchLineComment> publishedByPatch(Patch.Key patch)
+      throws OrmException;
 
   @Query("WHERE key.patchKey.patchSetId.changeId = ?"
       + " AND key.patchKey.fileName = ? AND status = '"
       + PatchLineComment.STATUS_PUBLISHED + "' ORDER BY lineNbr,writtenOn")
-  ResultSet<PatchLineComment> published(Change.Id id, String file)
+  ResultSet<PatchLineComment> publishedByChangeFile(Change.Id id, String file)
       throws OrmException;
 
   @Query("WHERE key.patchKey.patchSetId = ? AND status = '"
       + PatchLineComment.STATUS_PUBLISHED + "'")
-  ResultSet<PatchLineComment> published(PatchSet.Id patchset)
+  ResultSet<PatchLineComment> publishedByPatchSet(PatchSet.Id patchset)
       throws OrmException;
 
   @Query("WHERE key.patchKey.patchSetId = ? AND status = '"
       + PatchLineComment.STATUS_DRAFT
       + "' AND author = ? ORDER BY key.patchKey,lineNbr,writtenOn")
-  ResultSet<PatchLineComment> draft(PatchSet.Id patchset, Account.Id author)
+  ResultSet<PatchLineComment> draftByPatchSetAuthor
+      (PatchSet.Id patchset, Account.Id author)
       throws OrmException;
 
   @Query("WHERE key.patchKey = ? AND status = '"
       + PatchLineComment.STATUS_DRAFT
       + "' AND author = ? ORDER BY lineNbr,writtenOn")
-  ResultSet<PatchLineComment> draft(Patch.Key patch, Account.Id author)
+  ResultSet<PatchLineComment> draftByPatchAuthor
+      (Patch.Key patch, Account.Id author)
       throws OrmException;
 
   @Query("WHERE key.patchKey.patchSetId.changeId = ?"
       + " AND key.patchKey.fileName = ? AND author = ? AND status = '"
       + PatchLineComment.STATUS_DRAFT + "' ORDER BY lineNbr,writtenOn")
-  ResultSet<PatchLineComment> draft(Change.Id id, String file, Account.Id author)
+  ResultSet<PatchLineComment> draftByChangeFileAuthor
+      (Change.Id id, String file, Account.Id author)
       throws OrmException;
 
   @Query("WHERE status = '" + PatchLineComment.STATUS_DRAFT
diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/ReviewDb.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/ReviewDb.java
index b75b91b..08d6783 100644
--- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/ReviewDb.java
+++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/ReviewDb.java
@@ -32,85 +32,85 @@
 public interface ReviewDb extends Schema {
   /* If you change anything, update SchemaVersion.C to use a new version. */
 
-  @Relation
+  @Relation(id = 1)
   SchemaVersionAccess schemaVersion();
 
-  @Relation
+  @Relation(id = 2)
   SystemConfigAccess systemConfig();
 
-  @Relation
+  @Relation(id = 3)
   ApprovalCategoryAccess approvalCategories();
 
-  @Relation
+  @Relation(id = 4)
   ApprovalCategoryValueAccess approvalCategoryValues();
 
-  @Relation
+  @Relation(id = 5)
   ContributorAgreementAccess contributorAgreements();
 
-  @Relation
+  @Relation(id = 6)
   AccountAccess accounts();
 
-  @Relation
+  @Relation(id = 7)
   AccountExternalIdAccess accountExternalIds();
 
-  @Relation
+  @Relation(id = 8)
   AccountSshKeyAccess accountSshKeys();
 
-  @Relation
+  @Relation(id = 9)
   AccountAgreementAccess accountAgreements();
 
-  @Relation
+  @Relation(id = 10)
   AccountGroupAccess accountGroups();
 
-  @Relation
+  @Relation(id = 11)
   AccountGroupNameAccess accountGroupNames();
 
-  @Relation
+  @Relation(id = 12)
   AccountGroupMemberAccess accountGroupMembers();
 
-  @Relation
+  @Relation(id = 13)
   AccountGroupMemberAuditAccess accountGroupMembersAudit();
 
-  @Relation
+  @Relation(id = 14)
   AccountGroupIncludeAccess accountGroupIncludes();
 
-  @Relation
+  @Relation(id = 15)
   AccountGroupIncludeAuditAccess accountGroupIncludesAudit();
 
-  @Relation
+  @Relation(id = 16)
   AccountGroupAgreementAccess accountGroupAgreements();
 
-  @Relation
+  @Relation(id = 17)
   AccountDiffPreferenceAccess accountDiffPreferences();
 
-  @Relation
+  @Relation(id = 18)
   StarredChangeAccess starredChanges();
 
-  @Relation
+  @Relation(id = 19)
   AccountProjectWatchAccess accountProjectWatches();
 
-  @Relation
+  @Relation(id = 20)
   AccountPatchReviewAccess accountPatchReviews();
 
-  @Relation
+  @Relation(id = 21)
   ChangeAccess changes();
 
-  @Relation
+  @Relation(id = 22)
   PatchSetApprovalAccess patchSetApprovals();
 
-  @Relation
+  @Relation(id = 23)
   ChangeMessageAccess changeMessages();
 
-  @Relation
+  @Relation(id = 24)
   PatchSetAccess patchSets();
 
-  @Relation
+  @Relation(id = 25)
   PatchSetAncestorAccess patchSetAncestors();
 
-  @Relation
+  @Relation(id = 26)
   PatchLineCommentAccess patchComments();
 
-  @Relation
+  @Relation(id = 27)
   TrackingIdAccess trackingIds();
 
   /** Create the next unique id for an {@link Account}. */
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PublishComments.java b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PublishComments.java
index 1d43453..34194af 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PublishComments.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PublishComments.java
@@ -280,7 +280,7 @@
   }
 
   private List<PatchLineComment> drafts() throws OrmException {
-    return db.patchComments().draft(patchSetId, user.getAccountId()).toList();
+    return db.patchComments().draftByPatchSetAuthor(patchSetId, user.getAccountId()).toList();
   }
 
   private void email() {
diff --git a/pom.xml b/pom.xml
index a984a83..366b6bd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,7 @@
 
   <properties>
     <jgitVersion>1.0.0.201106090707-r.19-g8d88a84</jgitVersion>
-    <gwtormVersion>1.1.5</gwtormVersion>
+    <gwtormVersion>1.2-SNAPSHOT</gwtormVersion>
     <gwtjsonrpcVersion>1.2.5</gwtjsonrpcVersion>
     <gwtexpuiVersion>1.2.4</gwtexpuiVersion>
     <gwtVersion>2.3.0</gwtVersion>