当前位置: 代码迷 >> Java Web开发 >> 求HQL语句 急
  详细解决方案

求HQL语句 急

热度:4539   发布时间:2013-02-25 21:19:02.0
求HQL语句 急啊 在线等
sql = select * from Data where adddate between "+addDate+" and "+endDate+" and fkpiname = "+name+""
  这句话 怎么写成HQL语句

------解决方案--------------------------------------------------------
return this.getHibernateTemplate().find("select * from Data where adddate between ?and ? and fkpiname = ?",
new Object[] {name,addDate,endDate});

------解决方案--------------------------------------------------------
sql = select * from Data where adddate between "+addDate+" and "+endDate+" and fkpiname = "+name+""
 
换成 sql="from Data where adddate between "+addDate+" and "+endDate+" and fkpiname = "+name+""
 

------解决方案--------------------------------------------------------
hql="from Data where adddate >="+addDate+" and adddate<="+endDate+" and fkpiname = "+name;
------解决方案--------------------------------------------------------
Java code
hql = "from Data where adddate between '"+addDate+"' and '"+endDate+"' and fkpiname = '"+name+"'";
------解决方案--------------------------------------------------------
不需要进行日期转换吗
------解决方案--------------------------------------------------------
hql和sql没有区别呀
sql怎么写,hql就怎么写
------解决方案--------------------------------------------------------
探讨

return this.getHibernateTemplate().find("select * from Data where adddate between ?and ? and fkpiname = ?",
new Object[] {name,addDate,endDate});
  相关解决方案