如何从嵌套if中的If条件中得出?

时间:2019-02-14 08:51:55

标签: hibernate

我正在将工作类型与工作创建日期进行比较,它在一种情况下可以正常工作,但是如果我在对另一种条件进行整数运算,则它不能工作。

Let Job Types be Full Time and Internship

if ((filter.getFullTime() != null && !filter.getFullTime().isEmpty()) && (filter.getSevenday() != null || filter.getTwo() != null || filter.getFourteenday() != null || filter.getThirtyday() != null || filter.getHour() != null)) {                
    LOG.info("1 If condition is called");
    Conjunction con = Restrictions.conjunction();
    Criterion id2 = Restrictions.eq("job_type", filter.getFullTime());
    con.add(id2);
    Criterion id18 = Restrictions.between("job_createddate", filter.getSevenday(), filter.getCurrentdate());
    Criterion id19 = Restrictions.between("job_createddate", filter.getTwo(), filter.getCurrentdate());
    Criterion id20 = Restrictions.between("job_createddate", filter.getFourteenday(), filter.getCurrentdate());
    Criterion id21 = Restrictions.between("job_createddate", filter.getThirtyday(), filter.getCurrentdate());
    Criterion id22 = Restrictions.between("job_createddate", filter.getHour(), filter.getCurrentdate());
    myQueryDisjunc.add(id18);
    myQueryDisjunc.add(id19);
    myQueryDisjunc.add(id20);
    myQueryDisjunc.add(id21);
    myQueryDisjunc.add(id22);
    cr.add(con);
    cr.add(myQueryDisjunc);
}else {               
    Criterion id1 = Restrictions.eq("job_type", filter.getFreelance());
    Criterion id2 = Restrictions.eq("job_type", filter.getFullTime());
    Criterion id3 = Restrictions.eq("job_type", filter.getInternship());
    Criterion id4 = Restrictions.eq("job_type", filter.getPartTime());
    Criterion id5 = Restrictions.eq("job_type", filter.getTemporary());
    Criterion id6 = Restrictions.eq("job_type", filter.getVolunteer());
    myQueryDisjunc.add(id1);
    myQueryDisjunc.add(id2);
    myQueryDisjunc.add(id3);
    myQueryDisjunc.add(id4);
    myQueryDisjunc.add(id5);
    myQueryDisjunc.add(id6);
}

如果条件给出的是7天或所选的任何其他天的全职工作的数据。但是,如果我选择实习工作,那么它应该转到其他条件,但仍然可以与条件条件一起使用。

0 个答案:

没有答案