我试图在 HQL(选择)中指定我想要的字段。但是当我这样做时,我不断遇到这个奇怪的问题。
错误信息
java.lang.NumberFormatException: For input string: "staffId"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
java.lang.Integer.parseInt(Integer.java:492)
java.lang.Integer.parseInt(Integer.java:527)
javax.el.ArrayELResolver.coerce(ArrayELResolver.java:166)
javax.el.ArrayELResolver.getValue(ArrayELResolver.java:46)
org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
org.apache.el.parser.AstValue.getValue(AstValue.java:183)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:1026)
org.apache.jsp.views.search.SearchResults_jsp._jspx_meth_c_005fforEach_005f0(SearchResults_jsp.java:209)
org.apache.jsp.views.search.SearchResults_jsp._jspx_meth_c_005fif_005f0(SearchResults_jsp.java:165)
org.apache.jsp.views.search.SearchResults_jsp._jspService(SearchResults_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
org.apache.jasper.runtime.PageContextImpl.doInclude(PageContextImpl.java:684)
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:678)
org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:103)
org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96)
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
org.apache.tiles.renderer.impl.ChainedDelegateAttributeRenderer.write(ChainedDelegateAttributeRenderer.java:76)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:336)
org.apache.tiles.template.InsertAttributeModel.renderAttribute(InsertAttributeModel.java:210)
org.apache.tiles.template.InsertAttributeModel.end(InsertAttributeModel.java:126)
org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:311)
org.apache.jsp.views.templates.Layout_jsp._jspx_meth_tiles_005finsertAttribute_005f2(Layout_jsp.java:344)
org.apache.jsp.views.templates.Layout_jsp._jspService(Layout_jsp.java:182)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:241)
org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:222)
org.apache.tiles.renderer.impl.TemplateAttributeRenderer.write(TemplateAttributeRenderer.java:44)
org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:106)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:670)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:690)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:644)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:627)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:321)
org.springframework.web.servlet.view.tiles2.TilesView.renderMergedOutputModel(TilesView.java:124)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
我的 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%')";
我的模型类的片段
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;
}
我的 hbm XML 片段
<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" />
我查看了我的 Oracle 数据库并确认“staffId”确实是字符串(在我的情况下为 varchar2)。
你能帮忙吗?谢谢