分類  >  Web前端 >

利用hibernate查詢語句查詢信息,默認當日,不然往前推

tags:    時間:2013-12-09 23:28:30
利用hibernate查詢語句查詢信息,默認當日,否則往前推
	 public List<AhemcQualityAir> selectcheckQualityAir(final String time) { final String hql= "select air from AhemcQualityAir air where air.isDelete=0 and air.strtes1=1 and air.reportDate=? order by  air.cityname asc"; List<AhemcQualityAir> list = getHibernateTemplate().executeFind( new HibernateCallback() { public Object doInHibernate(Session session)throws HibernateException, SQLException { List<AhemcQualityAir> list = null; Query query = session.createQuery(hql);// for (int i = 0; i >-10; i--) {			 String time1=DateUtil.calculateDateByNumber(i); query.setDate(0, DateUtil.stringToUtilDate(time1)); list = query.list(); if (list != null && list.size() > 0) { break; }							 } return list; } }); return list; } 

推薦閱讀文章

Bookmark the permalink ,來源:互聯網