Don't allow multiple queries with the same method name

Require that the query name be unique within the access
interface, so that the implementation can use it as the
index name within the data store.

Change-Id: I7e73878c8b12a7ae8a758d84025c5383343c100b
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtorm/schema/RelationModel.java b/src/main/java/com/google/gwtorm/schema/RelationModel.java
index 85c440f..de323f8 100644
--- a/src/main/java/com/google/gwtorm/schema/RelationModel.java
+++ b/src/main/java/com/google/gwtorm/schema/RelationModel.java
@@ -104,7 +104,13 @@
     }
   }
 
-  protected void addQuery(final QueryModel q) {
+  protected void addQuery(final QueryModel q) throws OrmException {
+    for (QueryModel e : queries) {
+      if (e.getName().equals(q.getName())) {
+        throw new OrmException("Duplicate query " + q.getName() //
+            + " in " + getAccessInterfaceName());
+      }
+    }
     queries.add(q);
   }