使用struts1+spring+hibernatehibernateTemplate.find("select distinct m from Module m join fetch m.operations");只要一加上“select distinct m ”就报错             could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query

解决方案 »

  1.   

    写sql 用SQLQuery 吧 可以避免很多麻烦
      

  2.   

    我一直都这样用的啊     以前struts2+spring+hibernate就行  不知道今天怎么就不行了
      

  3.   

    你看你distinct 后面,m是什么,m后面应该有查询的内容吧,m.XXX
      

  4.   

    我看过一篇文章上说。。不管什么数据库 一定不要用 select * 或 count(*)、还有就是你说的 distinct  这些语句都是最浪费效率的。。你可以试试在后来控制。。例如你取出来的时候不用list集合用set集合也是可以去掉重复记录的。。个人拙见
      

  5.   

    distinct  还是少用比较好  降低效率
      

  6.   

    没有必要的:select employee form Employee as employee 
    select distinct employee.name from Employee as employee Hibernate查询语言:HQL 
    http://www.phome.asia/forum/thread/17598.html