现有记录验证

时间:2018-01-18 08:51:39

标签: java sql

我想检查我的申请表中是否有现有的申请人记录。如果没有继续填写表格的新申请。

这是我的方法:

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

0 个答案:

没有答案
相关问题