我必须选择用户输入的日期(liferay 日期选择器)并在 jsp 上显示基于该日期的内容。默认情况下,当页面加载时,日期将是当前日期,因此应显示当前日期的数据。
我正在使用自定义查询并在 jsp 中进行如下调用:
List<Object[]> ObjdisplayAttListName = AttendanceLocalServiceUtil.findAttendance(currdate);
currdate是应显示其数据的日期
在自定义查询中,我有:
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;
我总是得到一个空指针异常。我如何获得 NPE?当我写出出席.attDate LIKE 时,我的查询是否正确? 在我的jsp中,我有表单内的日期选择器。该日期还用于通过在 java 类中传递数据来处理数据。我应该如何提取此日期并将其发送到自定义查询?
这是我的 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;
}
}