我想检查我的申请表中是否有现有的申请人记录。如果没有继续填写表格的新申请。
这是我的方法:
public List<Tbcifindividual> existingApplication(String lastname, String firstname, Date dob) {
// TODO Auto-generated method stub
DBService dbservice = new DBServiceImpl();
Map<String,Object> params = HQLUtil.getMap();
List<Tbcifindividual> list = new ArrayList<Tbcifindividual>();
try {
params.put("lastname", lastname);
params.put("firstname", firstname);
params.put("dob", dob);
System.out.println("lastname >>>>>>>: " +lastname);
System.out.println("firstname>>>>>>>: " +firstname);
System.out.println("dob>>>>>>>>>: " +dob);
list = (List<Tbcifindividual>)dbservice.executeListHQLQuery("FROM Tbcifindividual WHERE firstname=:firstname"
+ " and lastname=:lastname and CONVERT(DATE,dateofbirth,120)=CONVERT(DATE,:dob,120)", params);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return list;
}
问题出在查询
中FROM Tbcifindividual WHERE firstname=:firstname and lastname=:lastname and CONVERT(DATE,dateofbirth,120)=CONVERT(DATE,:dob,120)
当我输入现有记录时它会起作用。
sample(existing record in my table)
firstname: test
lastname: test
DOB: 1/1/1991
output: you have a pending application.
我将在dojogrid
但是当我尝试输入差异时。 DOB
sample: (doesn't exist in my table for pending applicant)
fistname: test
lastname: test
DOB: 1/1/1990
output: you have a pending application.
但dojogrid
上没有显示任何记录,因为它假定为新应用程序,因为DOB
与现有记录不同
这是sysout的结果:
lastname >>>>>>>: TEST
firstname>>>>>>>: TEST
dob>>>>>>>>>: Sun Jan 01 02:00:00 SGT 1990