Store columns and fields in insertion order in RelationModel

Using a TreeMap to store column names causes them to be iterated in
sorted order when generating the SQL SELECT/INSERT clause in e.g.
RelationalModel.getInsertOneSQL. In the code to generate bytecode for
binding values to PreparedStatements for those same statements, in e.g.
AccessGen.implementBindOne, however, it uses the original insertion
order of the fields, and expands nested fields recursively in-place.
Since column names belonging to nested fields don't have any sort of
prefix, this means they get sorted at arbitrary places in the full
list of column names. This causes at best type mismatches[1] and at
worst corrupt data.

Change the column names in RelationModel to use the same original
iteration order that comes out of the JavaRelationModel. This calls
Class.getDeclaredFields and is thus not guaranteed stable across runs
in Java 7+, but for our purposes it just needs to be stable across a
single run.

This change is much simpler to implement than changing the iteration
order in the generated bytecode.

[1] For example:
org.h2.jdbc.JdbcSQLException: Data conversion error converting "'N'
(ACCOUNTS: MAXIMUM_PAGE_SIZE SMALLINT DEFAULT 0 NOT NULL)"; SQL
statement: INSERT INTO accounts(contact_filed_on,copy_self_on_email,
date_format,download_command,download_url,full_name,inactive,
maximum_page_size,preferred_email,registered_on,
reverse_patch_set_order,show_site_header,
show_username_in_review_category,time_format,use_flash_clipboard,
account_id)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) -- (?1, ?2, ?3, ?4,
?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16)

Change-Id: Ie8439a199ce74cb85e2a6f1cc2b981bce22c278d
1 file changed