title: How can I to order an EntityQuery query in a seam app?
body: <p>My project was originally generated by seam-gen and the action "List" bean, OfficeViewList looks pretty much like it did when first generated.</p>
  
  <p>The bean extends EntityQuery.</p>
  
  <p>Now I want to order the results. What is the best way to do this?</p>
  
  <p>Do I want to add some kind of "order by" class to my EJBQL?  Or do I want to set the select order via </p>
  
  <p>Here is the code that seam-gen generated (I have changed the RESTRICTIONS, but otherwise it's the same):</p>
  
  <pre><code>private static final String EJBQL = 
          "select officeView from OfficeView officeView";
  
  private static final String[] RESTRICTIONS = {
    "lower(officeView.addr1) like concat(lower(#{officeViewList.officeView.addr1}),'%')",
    "lower(officeView.buildingId) like  
       concat(lower({officeViewList.officeView.buildingId}),'%')",
    "lower(officeView.circuitId) like 
       concat('%',lower({officeViewList.officeView.circuitId}),'%')",};
  
  
  public OfficeViewList() {
    setEjbql(EJBQL);
    setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
    setMaxResults(25);
  }
  </code></pre>
  
  <p>The SQL translation is roughly </p>
  
  <blockquote>
    <p>select * from office_view where  order by office_id</p>
  </blockquote>
  
  <p>I was thinking to use setOrder or setOrderColumn, like this</p>
  
  <pre><code>public OfficeViewList() {
    setEjbql(EJBQL);
    setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
    setOrderColumn("office_id"); 
    setMaxResults(25);
  }
  </code></pre>
  
  <p>but I can't quite figure out how to do it or whether either of these are appropriate.  I can't find any documentation that really explains how to use these.</p>
  
  <p>Or do I add some kind of "order by" clause to by EJBQL statement? </p>
  
  <p>Or is there an annotation to add to my entity bean?   or to the constructor?</p>
  
  <p>Too many choices, not enough knowledge.</p>
  
  <p>Thank you in advance.</p>
  
  <p>TDR</p>