title: Hibernate + Derby: Comparisons between 'BOOLEAN' and 'INTEGER' are not supported
body: <p>I have a problem with querying Derby database. I am using Hibernate with JPA. Problem is related (probably) to boolean columns. Each query ends with error:</p>
  
  <p><em>org.hibernate.exception.SQLGrammarException: Comparisons between 'BOOLEAN' and 'INTEGER' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1')</em></p>
  
  <p>Below you may find sample code and configuration. Samples are simplified for easier reading. Here is my JPA entity:</p>
  
  <pre><code>@Entity
  public abstract class Task implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.TABLE)
      protected long id;
  
      @Column
      protected boolean deleted;
  
      public long getId() {
          return id;
      }
  
      public boolean isDeleted() {
          return deleted;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public void setDeleted(boolean deleted) {
          this.deleted = deleted;
      }
  
      @Override
      public int hashCode() {
          return id;
      }
  
      @Override
      public boolean equals(Object object) {
          if (object == null) {
              return false;
          }
  
          if (!this.getClass().equals(object.getClass())) {
              return false;
          }
  
          EntityObject other = (EntityObject) object;
  
          if (this.id != other.id) {
              return false;
          }
  
          return true;
      }
  
      @Override
      public String toString() {
          return "EntityObject[ id=" + id + " ]";
      }
  }
  </code></pre>
  
  <p>My JPA query:</p>
  
  <pre><code>SELECT t FROM Task t WHERE deleted = false
  </code></pre>
  
  <p>My JPA configuration:</p>
  
  <pre><code>&lt;persistence-unit name="PU1" transaction-type="JTA"&gt;
  &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
  &lt;jta-data-source&gt;jdbc/myapp&lt;/jta-data-source&gt;
  &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
  &lt;properties&gt;
    &lt;property name="hibernate.hbm2ddl.auto" value="update"/&gt;
    &lt;property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/&gt;
  &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>What is wrong? How to fix that? Thanks for any suggestions.</p>