title: Date within two date columns based on some condition in Hibernate
body: <p>I have a table in which there are two timestamp columns that represents <code>effective</code> and <code>expiration</code> dates and I need to fetch those rows where the current timestamp falls in those two date columns.</p>
  
  <p>This can be done by putting condition in SQL query as follows<br>
    <code>effectiveDate &lt;= current_timestamp and current_timestamp &lt; expirationDate</code>.</p>
  
  <p>The issue is that the above condition is to be satisfied if <code>expirationDate</code> is not null. If it is null, then only<br>
  <code>effectiveDate &lt;= current_timestamp</code> will be checked.</p>
  
  <p>This is a sort of some dynamic SQL, i guess. I am using Hibernate in the project. i can use either critera API or HQL or SQL anything.</p>
  
  <p>Please let me know how this can be done.</p>