sql=select * from pda_task_error_type_count_v ptetc where sql_const.setValue(10)=0 and sql_const.setDateValue1(‘开始时间’) is not null and sql_const.setDateValue2('结束时间') is not nullbuffer.append(sql);但是find(buffer.toString(), "");hibernate在执行的时候会报错在hql语句中不支持 is not null,            请问要怎么改?怎么改最简单?
我把is not null改成 not null,!=,<>;这些都不对异常被捕获如下:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: * near line 1, column 8 [select * from pda_task_error_type_count_v ptetc   where  sql_const.setValue(10)=0  and sql_const.setDateValue1(TO_DATE('20090616112242','YYYYMMDDHH24MISS'))<>null and sql_const.setDateValue2(TO_DATE('20090616112242','YYYYMMDDHH24MISS'))<>null]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 8 [select * from pda_task_error_type_count_v ptetc   where  sql_const.setValue(10)=0  and sql_const.setDateValue1(TO_DATE('20090616112242','YYYYMMDDHH24MISS'))<>null and sql_const.setDateValue2(TO_DATE('20090616112242','YYYYMMDDHH24MISS'))<>null]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:917)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:913)

解决方案 »

  1.   

    最好是只改is not null,这样最方便,就不用改其他的地方。hql中is not null 是怎么写的?  用的是hibernate3
      

  2.   

    没有select * 
    啊,多加了
      

  3.   

    hibernate操作的是类
    想清楚了再写
      

  4.   

    怎么这样写了,在Hibernate中使用SQL查询Query.createSQLQuery("SQL");
    再者Hibernate不支持Select *;在Hibernate中使用Select 称之为投影查询应指定查询的具体字段,
    HQL
    session.createQuery("from pda_task_error_type_count_v ptetc where sql_const.setValue(10)=0 and sql_const.setDateValue1(‘开始时间’) is not null and sql_const.setDateValue2('结束时间') is not null ");
      

  5.   

    我的问题是is not null 在hibernate中用什么代替掉hql 里面跟sql里面不一样,hql不能用is not null
      

  6.   

    只能采用条件查询了!
    eg: session.createCriteria(User.class)
           .add( Restrictions.or( 
                 Restrictions.eq("age",new Integer(0))
                 Restrictions.isNull("age")
            )).list();类似这样的你看行吗?