Hello!
I need the "INNER JOIN FETCH" because the DueDate and the DueDateDetail are a master-detail joining. I know it is a little bit confusing because the d.duedate is a Set of dueDates and the dueDate is a Date.
I found out that the questioning for the exact date (date, hours, minutes and seconds) is not the best way to compare java.Util.Date ;-)
Therefore I generated two new dates to investigate my data.
Code:
Date toDate = new Date(date.getYear(), date.getMonth(), date.getDate()+1,0,0,0);
Date fromDate = new Date(date.getYear(), date.getMonth(), date.getDate(),0,0,0);
[...]
Query query = em
.createQuery("FROM duedate.DueDateDetail d "
+ " INNER JOIN FETCH d.duedate "
+ " WHERE date(d.dueDate) < :toDate "
+ " AND date(d.dueDate) > :fromDate ");
This query returns all dates from the date 'fromDate'. Additionally I used the 'date(...)' to surround my database date-field - I found the 'date(..)' in this forum but I have not tried out it without - maybe it works too.
best regards,
Alex