I'm trying to get the books that were loaned between two dates. Since data has the lovely 2009 is shown as 109 feature I decided to use calendars.
However when writing my HQL I ran into the problem that BETWEEN doesn't view a Calendar as a date. Now I'm wondering if there's a solution for this. Or am I stuck writing functions in my class to get the hour, day, month, year and write a long where statement?
query = session.createQuery("from model.Book book where book.loaned between :earliest and :latest");
The problem is that the between only works with a date开发者_Go百科 object. and loaned is Javva.Util.Calendar.
You can get a Date
from a Calendar
using Calendar.getTime
- does that help you? You may run into time zone issues if you're not careful, admittedly... how exactly are the dates stored in the database?
精彩评论