日期:2014-05-16 浏览次数:20579 次
DateFormat datef = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = datef.parse(cd);
public Map getSmsContentByCateoryIdOrDate(Long id, Date date) { Map<String,List> map = new HashMap<String,List>(); final String hq1 = "from SmsContent s where s.category.id="+id+" and s.deleteTime>:expTime"; final String hq2 = "from SmsContent s where s.category.id="+id+" and s.updateTime>:expTime"; final String hq3 = "from SmsContent s where s.category.id="+id+" and s.creationTime>:expTime"; map.put("deletedContentList",getListByName(hq1,date)); map.put("updatedContentList",getListByName(hq2,date)); map.put("addedContentList",getListByName(hq3,date)); map.put("allContentList",null); return map; } //根据参数名返回List private List getListByName(final String hql,final Date date){ List list = (List)this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.createQuery(hql).setTimestamp("expTime",date).list(); } }); return list; }
public List statisticsSmsContentByDate(final Date beginDate,final Date endDate) { return (List)this.getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.createCriteria(SmsContent.class).add(Restrictions.ge("creationTime",beginDate)) .add(Restrictions.lt("creationTime",endDate)).list(); //session.createQuery("ssss :begin :end").setTimestamp().list(); } }); }