尝试指定要检索的字段时,Hibernate出现奇怪的错误

尝试指定要检索的字段时,Hibernate出现奇怪的错误,hibernate,hql,Hibernate,Hql,我试图在HQL select中指定所需的字段。但当我这么做的时候,我总是遇到这个奇怪的问题 错误消息 正如您所看到的,我的HQL当前设置为给出错误的那个。但那个被注释掉的很好用 //SQL = "from Staff where (surnameSearch is not null) and not (nvl(teleDirectory,'xxx') IN ('N','S','D')) and not (telephoneNumber IS NULL AND alias IS NULL)

我试图在HQL select中指定所需的字段。但当我这么做的时候,我总是遇到这个奇怪的问题

错误消息

正如您所看到的,我的HQL当前设置为给出错误的那个。但那个被注释掉的很好用

    //SQL = "from Staff where (surnameSearch is not null) and not (nvl(teleDirectory,'xxx') IN ('N','S','D')) and not (telephoneNumber IS NULL AND alias IS NULL) and (aliasList = 'Y' OR (teleDirectory IN ('A','B'))) and ((nvl(systemIdEnd,sysdate+1) > SYSDATE and entityType = 'P') or (entityType = 'N')) and (departmentSearch NOT like 'SPONSOR%')";
    SQL = "select staffId, parentId, entityType, title, firstname, surname, telephoneNumber, department, role from Staff where (surnameSearch is not null) and not (nvl(teleDirectory,'xxx') IN ('N','S','D')) and not (telephoneNumber IS NULL AND alias IS NULL) and (aliasList = 'Y' OR (teleDirectory IN ('A','B'))) and ((nvl(systemIdEnd,sysdate+1) > SYSDATE and entityType = 'P') or (entityType = 'N')) and (departmentSearch NOT like 'SPONSOR%')";
我也尝试过这个,但没有任何运气

    SQL = "select staff.staffId, staff.parentId, staff.entityType, staff.title, staff.firstname, staff.surname, staff.telephoneNumber, staff.department, staff.role from Staff staff where (surnameSearch is not null) and not (nvl(teleDirectory,'xxx') IN ('N','S','D')) and not (telephoneNumber IS NULL AND alias IS NULL) and (aliasList = 'Y' OR (teleDirectory IN ('A','B'))) and ((nvl(systemIdEnd,sysdate+1) > SYSDATE and entityType = 'P') or (entityType = 'N')) and (departmentSearch NOT like 'SPONSOR%')";
我的模型类的片段

我的hbm XML的片段

我已经查看了我的Oracle数据库,并确认在我的例子中,staffId确实是string或varchar2

你能帮忙吗?谢谢

您已将staffid映射到列telsum\u id:


telsumm_id很可能是一个整数列,因为它的名称以_id

结尾,我已经在oracle表中查找过,并且该字段被声明为varchar2。似乎即使该字段被声明为varchar2,也没有id以零开头的记录。从我的_表中选择count*,此处substrertelsumm_id,1,1='0'即使我显式地声明字段是字符串,它也可能是Hibernate试图将其转换为整数的吗?
    SQL = "select staff.staffId, staff.parentId, staff.entityType, staff.title, staff.firstname, staff.surname, staff.telephoneNumber, staff.department, staff.role from Staff staff where (surnameSearch is not null) and not (nvl(teleDirectory,'xxx') IN ('N','S','D')) and not (telephoneNumber IS NULL AND alias IS NULL) and (aliasList = 'Y' OR (teleDirectory IN ('A','B'))) and ((nvl(systemIdEnd,sysdate+1) > SYSDATE and entityType = 'P') or (entityType = 'N')) and (departmentSearch NOT like 'SPONSOR%')";
public class Staff {
    Integer pk;
    String staffId;
    String parentId;
    String entityType;
    String title;
    String firstname;
    String surname;
    String telephoneNumber;
    String department;
    String role;

    String alias;
    String aliasList;
    String departmentSearch;
    String firstnameSearch;
    String roleSearch;
    String surnameSearch;
    String surnameLikeSearch;
    Date systemIdEnd;
    String teleDirectory;

    public Integer getPk() {
        return pk;
    }
    public void setPk(Integer pk) {
        this.pk = pk;
    }

    public String getStaffId() {
        return staffId;
    }
    public void setStaffId(String staffId) {
        this.staffId = staffId;
    }
<hibernate-mapping>
    <class name="org.flinders.staffdirectory.models.database.Staff" table="teld_summary">
        <id name="pk" column="telsumm_pk" />
        <property name="staffId" column="telsumm_id" />
<property name="staffId" column="telsumm_id" />