title: mybatis ordering by many fields with dynamic sql
body: <p>Is there a cleaner way of doing the next :</p>
  
  <pre><code>&lt;select id="getWithQueryData" resultMap="usuarioResult" parameterType="my.QueryData" &gt;
  select * from t_user 
   &lt;if test="fieldName != null and ascDesc != null"&gt;
      order by
          &lt;choose&gt;  
              &lt;when test="fieldName == 'name'"&gt;
                  c_name 
              &lt;/when&gt;         
              &lt;when test="fieldName == 'lastName'"&gt;
                  c_last_name 
              &lt;/when&gt; 
              &lt;when test="fieldName == 'email'"&gt;
                  c_email 
              &lt;/when&gt; 
              &lt;when test="fieldName == 'password'"&gt;
                  c_password 
              &lt;/when&gt; 
              &lt;when test="fieldName == 'age'"&gt;
                  i_age
              &lt;/when&gt;                                                             
          &lt;/choose&gt;               
          &lt;if test="ascDesc == 'asc'"&gt;
              asc 
          &lt;/if&gt;            
          &lt;if test="ascDesc == 'desc'"&gt;
              desc 
          &lt;/if&gt;   
   &lt;/if&gt;
  limit #{limit} offset #{offset};
  </code></pre>
  
  <p></p>
  
  <p>As you could infer, QueryData looks like:</p>
  
  <pre><code>public class FiltroBusquedaVO {
  
  private Integer offset;
  private Integer limit;
  private String fieldName;
  private String ascDesc; ... }
  </code></pre>
  
  <p>Would be nice if I could get a column name given a fieldName. I mean, the result maps have that info. But it seems I can not get it from the xml.</p>
  
  <p>My example has just 5 fields, but what about 20 fields? Is there another way around of doing this less verbose?</p>