hibernate 使用date条件

来源:互联网 发布:淘宝 直通车 编辑:程序博客网 时间:2024/05/20 19:45

SERVICE层:

String period = (String)queryCondition.get("period");

Calendar calendar = Calendar.getInstance();
  int day = calendar.get(Calendar.DATE);
  Date periodFormat = DateUtil.formDate(Integer.parseInt(period.substring(0, 4)), Integer.parseInt(period.substring(4, 6)) , day); // 传入当前的年月日
  queryCondition.put("date", periodFormat);

DAO层:

String hql = "from CpmOrg a where a.orgG = :orgg and a.porg = :porg  and a.frdate<= :date and (a.todate>= :date or a.todate is null) and a.fscard = 'Y' order by a.preorg";

原创粉丝点击