Hibernate errors in named queries
<p>I am trying to pull information from a table where the current date is between the first and last day of any given month.</p>

<p>I am getting a runtime error "Errors in named queries: Department.byDate"</p>

<p>I am providing you with what code I think could be causing the problem, if any additional code is needed please let me know in a comment.</p>

<p>My named query which looks like this: </p>

<pre><code>@NamedQuery(name="Department.byDate", query="select * from department where date &gt;= :first AND date &lt;= :last")
</code></pre>

<p>I am using this named query in my DAO in a method which looks like this: </p>

<pre><code>public List&lt;Department&gt; getRecords(Date dateFirst, Date dateLast){
    Session session= sessionFactory.openSession();
    session.beginTransaction();

    Query query = session.getNamedQuery("Department.byDate");
    query.setDate("first", dateFirst);
    query.setDate("last", dateLast);

    List&lt;Department&gt; depList = (List&lt;Department&gt;)query.list();

    session.getTransaction().commit();
    session.close();

    return depList;
}
</code></pre>

<p>My method of getting that first and last days of the months looks like this: </p>

<pre><code>Calendar first = Calendar.getInstance();
first.set(Calendar.getInstance().get(Calendar.YEAR), Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().getActualMinimum(Calendar.DAY_OF_MONTH));
Date dateFirst = first.getTime();

Calendar last = Calendar.getInstance();
first.set(Calendar.getInstance().get(Calendar.YEAR), Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH));
Date dateLast = last.getTime();
</code></pre>