Thank you mmerder that has worked, this is how I used it. I'm sure there was a better way of doing it in BEAN but this is how I did it.
Code:
@NamedQuery(name = "Invoice.findByInvoiceForWholeMonth", query = "SELECT i FROM Invoice i WHERE month(i.invoiceDate) = :month")
Code:
public List<Invoice> getInvoiceByWholeMonth(Integer month) {
em.getTransaction().begin();
List<Invoice> invDate = em.createNamedQuery("Invoice.findByInvoiceForWholeMonth")
.setParameter("month", month).getResultList();
em.getTransaction().commit();
return invDate;
}
In Bean
Code:
String string= invoiceObj.getInvoiceDate().toString();
String d = string.substring(6, 7);
int date = Integer.parseInt(d) ;
invoiceList = hibernateQueryManagerDao.getInvoiceByWholeMonth(date);
Many Thanks
Zed