title: query date by month and year with hibernate from database
body: <p>i have a named query where I want to fetch all records where year and month of a parameter match the database entry:</p>
  
  <pre><code>@NamedQuery(
          name = entries.queryX,
          query = "SELECT DISTINCT t from entries t " +
          "where MONTH(t.myMonth) = :month " +
          "and YEAR(t.myMonth) = :year "
  )
  </code></pre>
  
  <p>The value "myMonth" in table entries is a YearMonth:</p>
  
  <pre><code>@Column(name = "MY_MONTH", precision = 7)
  private YearMonth myMonth;
  </code></pre>
  
  <p>I set the query parameters as follows:</p>
  
  <pre><code>query.setParameter("month", date.get(Calendar.MONTH) + 1);
  query.setParameter("year", date.get(Calendar.YEAR));
  </code></pre>
  
  <p>However, this approach does not work... Is there any other way to implement what I want to search for?</p>