title: Is there a way to stop Hibernate from corrupting boolean literals in @Where annotations?
body: <p>I'd like to use <code>@Where</code> annotation in Hibernate to remove objects which have been marked 'deleted' by a boolean property on that object. For example the following should prevent any deleted addresses from being loaded by Hibernate:</p>
  
  <pre><code>@OneToMany(mappedBy="contact")
  @Where(clause="deleted=FALSE")
  private Set&lt;Address&gt; addresses; 
  </code></pre>
  
  <p>However when I use a clause like <code>deleted=FALSE</code> then Hibernate will mangle the boolean literal by prefixing it with a table name, which causes the query to fail. For example:</p>
  
  <pre><code>select ... from address address0_ where  ( address0_.deleted=address0_.FALSE)  and address0_.contact_id=?
  </code></pre>
  
  <p>What I expected is something like <code>(address0_.deleted=FALSE)</code> instead of <code>(address0_.deleted=address0_.FALSE)</code>. </p>
  
  <p>Is there a way to specify the @Where clause or configure Hibernate to correctly output the boolean value?</p>
  
  <hr>
  
  <p><em>PS.</em> Note that it is possible with <em>some</em> databases to specify the boolean value as a string literal like this:</p>
  
  <pre><code>@Where(clause="deleted='FALSE'")
  </code></pre>
  
  <p>That will get converted to <code>(address0_.deleted='FALSE')</code> which works just fine in, for example, PostgreSQL. However I am using HSQLDB for this project, and HSQLDB does not seem to support boolean string literals. On HSQL I get the following exception when using <code>deleted='FALSE'</code>:</p>
  
  <p><code>org.hsqldb.HsqlException: data exception: invalid character value for cast</code></p>