hibernate使用日期查询,查询年月日,不要时间


大于,小于,等于,大于等于,小于等于

 public List<实体类> getBetweenStartDateAndEndDate(
            Session session, int id, DateTime startDateTime, DateTime endDateTime) {
        DateTime endDate = endDateTime.plusDays(1);//查询日期必须要加1天,不然查不到今天创建的记录,要考虑23:59:59秒的问题
        StringBuffer hql = new StringBuffer(
                "FROM 实体类 WHERE poolid = '" + id + "' AND createDt >= '"
                + startDateTime.toString("yyyy-MM-dd") + "' AND createDt <'"
                + endDate.toString("yyyy-MM-dd") + "' ORDER BY id ASC");
        Query query = session.createQuery(hql.toString());
        List<实体类> cps = query.list();
        return cps;
    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM