hSession = HibernateUtilPlus.currentSession(); 打出 hSession 值看看
Query query = hSession.createQuery(hql); 如果确实是这句抛出异常,,有可能  hSession==null

解决方案 »

  1.   

    你的hibernate配置文件中的打印sql语句的状态是开吗? 如果是,看看控制台该语句,复制并在SQLServer中执行一下,看看结果是什么如果状态没开,将其打开,便于开发调试
      

  2.   

    hql中的各个class属性名字写的不对也出向这个问题
      

  3.   

    hSession不是null,hibernate配置文件中的打印sql语句的状态是开的,但是sql语句根本就还没解析出来,应该是解析的时候就出了问题。我数据库是oracle9i
      

  4.   

    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" ><hibernate-mapping>
    <!--
        Created by the Middlegen Hibernate plugin 2.1    http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
    --><class
        name="com.monitorcc.system.db.table.TabUser"
        table="TAB_USER"
    >
        <meta attribute="class-description" inherit="false">
           @hibernate.class
            table="TAB_USER"
        </meta>    <id
            name="userId"
            type="int"
            column="USER_ID"
            access="field"
        >
            <meta attribute="field-description">
               @hibernate.id
                generator-class="sequence"
                type="int"
                column="USER_ID"
                access="field"
               @hibernate.generator-param
            name="sequence"
            value="SEQ_USER"
            </meta>
            <meta attribute="use-in-equals">true</meta>
            <generator class="sequence">
                <param name="sequence">SEQ_USER</param>
            </generator>
        </id>    <property
            name="userName"
            type="java.lang.String"
            column="USER_NAME"
            not-null="true"
            length="10"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="USER_NAME"
                length="10"
                not-null="true"
            </meta>
        </property>
        <property
            name="userLoginName"
            type="java.lang.String"
            column="USER_LOGIN_NAME"
            length="20"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="USER_LOGIN_NAME"
                length="20"
            </meta>
        </property>
        <property
            name="userLoginPwd"
            type="java.lang.String"
            column="USER_LOGIN_PWD"
            length="40"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="USER_LOGIN_PWD"
                length="40"
            </meta>
        </property>
        <property
            name="userPhoneNo"
            type="java.lang.String"
            column="USER_PHONE_NO"
            length="15"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="USER_PHONE_NO"
                length="15"
            </meta>
        </property>
        <property
            name="userEmail"
            type="java.lang.String"
            column="USER_EMAIL"
            length="50"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="USER_EMAIL"
                length="50"
            </meta>
        </property>
        <property
            name="userStatus"
            type="int"
            column="USER_STATUS"
            length="1"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="USER_STATUS"
                length="1"
            </meta>
        </property>    <!-- Associations -->    <!-- bi-directional one-to-many association to TabPrivilege -->
        <set
            name="tabPrivileges"
            lazy="true"
            inverse="true"
    cascade="none"
        >
            <meta attribute="field-description">
               @hibernate.set
                lazy="true"
                inverse="true"
                cascade="all"           @hibernate.collection-key
                column="USER_ID"           @hibernate.collection-one-to-many
                class="com.monitorcc.system.db.table.TabPrivilege"
            </meta>
            <key>
                <column name="USER_ID" />
            </key>
            <one-to-many
                class="com.monitorcc.system.db.table.TabPrivilege"
            />
        </set></class>
    </hibernate-mapping>
    这是我表的映射文件,class属性的名字应该没写错啊
      

  5.   

    from TabUser as user inner join user.userId
    userId不是一张表吧?