title: Hibernate postgresql comparing date
body: <p>I'm using Hibernate and PostgreSQL 8.4 database in a Java application. I have the following query:</p>
  
  <pre><code>Query q = session.createQuery("from User where validStartDate &lt; "  + getDate() +" and validEndDate &gt;" + getDate());
  </code></pre>
  
  <p>where validStartDate is a Date in a PostgreSQL database and getDate returns a String from the current date by using the SimpleDateFormat.</p>
  
  <p>But I keep getting an error:</p>
  
  <pre><code>Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: date &lt; integer
          at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
          at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
          at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
          at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
          at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
          at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
          at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
          at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
          at org.hibernate.loader.Loader.doQuery(Loader.java:674)
          at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
          at org.hibernate.loader.Loader.doList(Loader.java:2220)
          ... 49 more
  2010-11-29 20:42:19 org.hibernate.util.JDBCExceptionReporter logExceptions
  WARNING: SQL Error: 0, SQLState: 42883
  2010-11-29 20:42:19 org.hibernate.util.JDBCExceptionReporter logExceptions
  SEVERE: ERROR: operator does not exist: date &lt; integer
  </code></pre>
  
  <p>How do I cast the value so it is of proper type Date rather than integer?</p>
  
  <p>Thanks for help.</p>