I have to pick up date (liferay date picker) entered by user and display the contents based on that date on jsp. By default when the page loads the date will be the current date and hence data of the current date should be displayed.
I am using custom query and making a call in the jsp as follows:
List<Object[]> ObjdisplayAttListName = AttendanceLocalServiceUtil.findAttendance(currdate);
The currdate is the date whose data should be displayed
In the custom query I have:
select stud.studName , stud.empTitle, attendance.attRemarks, attendance.attStatus , stud.fileEntryI from student stud left outer join attendance attendance on stud.studId = attendance.studId and attendance.attDate LIKE ? order by studName asc;
I always get a null pointer exception. How am I getting NPE? and is my query correct when I write attendance.attDate LIKE ? In my jsp I have the datepicker which is inside the form. this date is also used to process data by passing it in java class. How should I extract this date and send it to custom query?
Here is my FinderImpl:
public class AttendanceFinderImpl extends BasePersistenceImpl implements AttendanceFinder {
public static String FIND_Attendance = "findAttendance";
@SuppressWarnings("rawtypes")
public List findAttendance(Date attendanceDate) throws SystemException {
List attSearchList = null;
Session session = null;
try {
session = openSession();
String sql = CustomSQLUtil.get(FIND_Attendance);
System.out.println("session : " + session);
System.out.println("SQL QUERY CustomSQLUtil.get(findAttendance): " + CustomSQLUtil.get("findAttendance"));
SQLQuery query = session.createSQLQuery(sql);
System.out.println("SQLQuery : " + query);
//query.addEntity("Attendance", AttendanceImpl.class);
//query.addEntity("Employee", EmployeeImpl.class);
QueryPos qPos = QueryPos.getInstance(query);
System.out.println("I am returning the query : " + query);
System.out.println("List size.list: "+ query.list());
qPos.add(attendanceDate);
System.out.println("List size: "+ query.list().size());
return (List)query.list();
}catch (Exception e) {
}
return null;
}
}