I want to fetch all the records which match the today date but ignoring the year Date in database is like this 1980-11-14. Want to fetch the record only comparing month and day not the year. I tried it using Criteria but its not working. Here is my code.
Date date = new Date(); // your date
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int month = cal.get(Calendar.MONTH);
int day = cal.get(Calendar.DAY_OF_MONTH);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MONTH,month);
calendar.set(Calendar.DAY_OF_MONTH, day);
Calendar fromDate = calendar.getInstance();
calendar.set(Calendar.MONTH,month);
calendar.set(Calendar.DAY_OF_MONTH, day);
Calendar toDate = calendar.getInstance();
Criteria criteria=session.createCriteria(Add_Follower.class);
criteria.add(Restrictions.eq("follow_uInfo.id", uid));
criteria.add(Restrictions.between("following_uInfo.dob",fromDate,toDate));
users=criteria.list();
could not resolve property, I do not know, that's your code and your properties, you should be able to tell what's wrong, but I see that in one case you sayfollow_uInfoand in another case you sayfollowing_uInfo, could that be a hint? - Mike Nakis