Keep relations and columns sorted by name

Sorting by the order they are discovered from the class file may
be random under Java 7, leading to constantly changing output from
the ProtoFileGenerator. Instead use TreeSet to always sort by name.

Change-Id: Ib298edcb0db8940b53669dfdacc06a8f1e95f5fb
diff --git a/src/main/java/com/google/gwtorm/schema/RelationModel.java b/src/main/java/com/google/gwtorm/schema/RelationModel.java
index 665a6b2..dfa3753 100644
--- a/src/main/java/com/google/gwtorm/schema/RelationModel.java
+++ b/src/main/java/com/google/gwtorm/schema/RelationModel.java
@@ -23,8 +23,8 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -32,15 +32,15 @@
   protected String methodName;
   protected String relationName;
   protected Relation relation;
-  protected final LinkedHashMap<String, ColumnModel> fieldsByFieldName;
-  protected final LinkedHashMap<String, ColumnModel> columnsByColumnName;
+  protected final Map<String, ColumnModel> fieldsByFieldName;
+  protected final Map<String, ColumnModel> columnsByColumnName;
   protected final SortedMap<Integer, ColumnModel> columnsById;
   protected KeyModel primaryKey;
   protected Collection<QueryModel> queries;
 
   protected RelationModel() {
-    fieldsByFieldName = new LinkedHashMap<String, ColumnModel>();
-    columnsByColumnName = new LinkedHashMap<String, ColumnModel>();
+    fieldsByFieldName = new TreeMap<String, ColumnModel>();
+    columnsByColumnName = new TreeMap<String, ColumnModel>();
     columnsById = new TreeMap<Integer, ColumnModel>();
     queries = new ArrayList<QueryModel>();
   }
diff --git a/src/main/java/com/google/gwtorm/schema/SchemaModel.java b/src/main/java/com/google/gwtorm/schema/SchemaModel.java
index 3e6a28f..ca1b3ff 100644
--- a/src/main/java/com/google/gwtorm/schema/SchemaModel.java
+++ b/src/main/java/com/google/gwtorm/schema/SchemaModel.java
@@ -19,10 +19,9 @@
 
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
-
+import java.util.TreeMap;
 
 public abstract class SchemaModel {
   protected final Set<String> allNames;
@@ -31,8 +30,8 @@
 
   protected SchemaModel() {
     allNames = new HashSet<String>();
-    relations = new LinkedHashMap<String, RelationModel>();
-    sequences = new LinkedHashMap<String, SequenceModel>();
+    relations = new TreeMap<String, RelationModel>();
+    sequences = new TreeMap<String, SequenceModel>();
   }
 
   protected void add(final RelationModel r) throws OrmException {