在日期范围内搜索时没有值

nwlqm0z1  于 2021-07-09  发布在  Java
关注(0)|答案(0)|浏览(213)

为什么在使用hibernate搜索javamvc中的日期范围时没有值呢。在mysql测试中有一个值,但是当我要使用应用程序进行搜索时,没有结果。我的代码怎么了?
型号:

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
     private Date deliveryDate;
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    private LocalDate startDt;
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)  
    private LocalDate endDt;

    public LocalDate getStartDt() {
        return startDt;
    }
    public void setStartDt(LocalDate startDt) {
        this.startDt = startDt;
    }
    public LocalDate getEndDt() {
        return endDt;
    }
    public void setEndDt(LocalDate endDt) {
        this.endDt = endDt;
    }

查看:

<div class="form-group">
                    <div class="col-lg-8">
                        <button type="submit" class="btn btn-success"><b>SEARCH</b></button>
                        <form>
                        from <form:input path="startDt" name= "search"  type= "date" style="box-sizing:border-box; height:30px;"/>
                        to <form:input path="endDt"  name= "search" type= "date"  style="box-sizing:border-box; height:30px"/>
                        <input type= "submit" class="btn btn-success" style=height:30px;/>
                        </form>

                        <%-- <a class = "btn btn-primary" href = "<c:url value="/inventory/secured/admin/inventory/master/formAddItem"/>" ><b>CREATE</b></a> --%>
                        <br>
                        <br>
                        <%-- <a class="btn btn-primary" href="<c:url value="/inventory/secured/admin/inventory/master/form"/>">CREATE</a> --%>
                    </div>
                </div>

dao/休眠

if(sched.getStartDt()!=null && sched.getEndDt()!=null){
                dynamicSql.append("and DATE_FORMAT(ds.deliveryDate,'%y-%M-%d') between (:startDt) AND (:endDt)) ");
            }
if(sched.getStartDt()!=null && sched.getEndDt()!=null){
            query.setParameter("startDt","%"+sched.getStartDt()+"%").setParameter("endDt","%"+ sched.getEndDt()+"%");
            queryCount.setParameter("startDt", "%"+sched.getStartDt()+"%");
            queryCount.setParameter("endDt", "%"+sched.getEndDt()+"%");
         }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题