I was trying to specify the fields I want in an HQL (select). But when I do this, I keep on getting this weird problem.
error message Code:
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)
my HQL (as you can see it's currently set to the one that gives me the error. but the one commented out works fine)
Code:
//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%')";
I've also tried this without any luck.
Code:
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%')";
snippet of my model class Code:
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;
}
snippet of my hbm XML Code:
<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" />
I've looked into my Oracle DB and confirmed that the "staffId" is indeed string (or varchar2 in my case). But I looked at the data and it seems even though it is string, the data can be considered as number. verified using this SQL: select count(*) from my_table_here where substr(telsumm_id,1,1) = '0' (I got no records back). I can't just change the data definition as it's being used elsewhere. the only alternative I can see is to make a copy of the field and declare that as int. Though I'm hoping there is a hibernate solution to this in case I encounter it again in the future.
Can you please help? thanks :)