Generate AnyFooPrimaryKey protobuf message

This message contains all of the primary key fields of any relation
declared in the schema. It can be useful when trying to name an
entity in a generic way, as any primary key can be wrapped into this
message to denote both the relation and the specific item within it.

Change-Id: Ie8a8a33fc362edf4ff3dc7cced41e5b2851054c4
diff --git a/pom.xml b/pom.xml
index 16e7898..0104c36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
   <groupId>gwtorm</groupId>
   <artifactId>gwtorm</artifactId>
   <packaging>jar</packaging>
-  <version>1.4</version>
+  <version>1.5-SNAPSHOT</version>
   <name>gwtorm</name>
   <description>Tiny ORM</description>
   <url>http://android.git.kernel.org/?p=tools/gwtorm.git</url>
diff --git a/src/main/java/com/google/gwtorm/schema/java/ProtoFileGenerator.java b/src/main/java/com/google/gwtorm/schema/java/ProtoFileGenerator.java
index e0e47e4..0bbd524 100644
--- a/src/main/java/com/google/gwtorm/schema/java/ProtoFileGenerator.java
+++ b/src/main/java/com/google/gwtorm/schema/java/ProtoFileGenerator.java
@@ -83,14 +83,22 @@
       generateMessage(r, out);
     }
 
-    out.print("message Any" + schemaName + " {\n");
+    out.print("message Any" + schemaName + "PrimaryKey {\n");
+    for (RelationModel r : sortRelations(rels)) {
+      ColumnModel pk = r.getPrimaryKey().getField();
+      out.print("\toptional " + getType(pk) + " "
+          + r.getRelationName().toLowerCase() + " = " + r.getRelationID()
+          + ";\n");
+    }
+    out.print("}\n");
+    out.print("\n");
 
+    out.print("message Any" + schemaName + " {\n");
     for (RelationModel r : sortRelations(rels)) {
       out.print("\toptional " + getMessageName(r) + " "
           + r.getRelationName().toLowerCase() + " = " + r.getRelationID()
           + ";\n");
     }
-
     out.print("}\n");
   }