title: ORM Lite Android Unknown column name in table name
body: <p>I'm using <a href="http://ormlite.com/sqlite_java_android_orm.shtml" rel="nofollow noreferrer">ORM Lite</a> in my android application, I have a problem to do a search by filtering for a foreign field, I'll post my classes below:</p>
  
  <pre><code>public class Estabelecimento {
  
      @DatabaseField(generatedId = true)
      private int id;
  
      @DatabaseField
      public static long codigo;
  
      @ForeignCollectionField(eager=false)
      private Collection&lt;SituacaoProduto&gt; situacoesProduto;
  
          ...
  }
  
  public class SituacaoProduto {
  
      @DatabaseField(generatedId = true)
      private int id;
  
      @DatabaseField
      private long codigo;
  
      @DatabaseField
      private String situacao;
  
      @DatabaseField(foreign=true)
      private Produto produto;
  
      @DatabaseField(foreign=true,foreignAutoRefresh=true)
      private Estabelecimento estabelecimento;
  
          ...
  }
  </code></pre>
  
  <p>and this would be my find method:</p>
  
  <pre><code>public List&lt;SituacaoProduto&gt; findByEstabelecimento(Estabelecimento estabelecimento, Context context){
  
          List&lt;SituacaoProduto&gt; list = new ArrayList&lt;SituacaoProduto&gt;();
  
          try{
              Dao&lt;SituacaoProduto, Integer&gt; dao = getDatabase(context).getDao(SituacaoProduto.class);
              QueryBuilder&lt;SituacaoProduto, Integer&gt; qBuilder = dao.queryBuilder();
              // Monta select: (estabelecimento.codigo == codigoEstabelecimento)
              qBuilder.where().eq("estabelecimento.codigo", estabelecimento.getCodigo());
              PreparedQuery&lt;SituacaoProduto&gt; pQuery = qBuilder.prepare();
  
              // Recupera registro            
              list = dao.query(pQuery);
  
          }catch(SQLException e){
              e.printStackTrace();
              return null;
          }finally{
              if (database != null) {
                  OpenHelperManager.releaseHelper();
                  database = null;
              }
          }
  
          return list;
      }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>12-10 10:32:25.398: E/AndroidRuntime(19575):
    java.lang.IllegalArgumentException: Unknown column name
    'estabelecimento.codigo' in table situacaoproduto</p>
  </blockquote>
  
  <p>It's as if there was no reference to foreign cheve, if I put in my <code>estabelecimento_id</code> find method for searching it put me off errors, but need not filter by <code>codigo</code>, it is a code that comes from the Web Service:</p>
  
  <p>Here I found a solution, (<a href="https://stackoverflow.com/questions/11118350/ormlite-how-to-build-query-with-selecting-by-value-of-foreign-objects-field">link</a>) but I refuse to do this, declare class attributes as public static final is a bad practice</p>
  
  <p>some help?</p>