SqlServer integer fields cause Exceptions

  • Dirk Coetsee
    Dirk Coetsee

    For all the int fields in sqlServer I'm getting the following exception

    Aug 13, 2013 5:42:14 PM org.openxava.web.WebEditors formatToStringOrArrayImpl
    WARNING: java.lang.Integer cannot be cast to java.lang.String
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    at org.openxava.model.meta.MetaProperty.format(MetaProperty.java:999)
    at org.openxava.web.WebEditors.formatToStringOrArrayImpl(WebEditors.java:167)
    at org.openxava.web.WebEditors.formatToStringOrArray(WebEditors.java:128)
    at org.openxava.web.WebEditors.format(WebEditors.java:108)
    at org.apache.jsp.xava.editors.listEditor_jsp._jspService(listEditor_jsp.java:1059)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at ...........

    the type field contains int as class Type but it should be Integer at that point.


  • Javier Paniza
    Javier Paniza

    Hi Dirk,

    that is because the type in Java and the DB does not match. Surely, because you have defined columns in DB as VARCHAR while in Java are ints.

    Please, put here the code of your Java class and the CREATE TABLE for your table creation. We will try to give a more accurate tip.

    Ayuda a otros en este foro como yo te ayudo a ti.
    ¿Necesitas más ayuda? Usa el soporte profesional de OpenXava

  • Dirk Coetsee
    Dirk Coetsee

    Hi Javier, I got to the bottom of the problem. The Java fields were generated as UpperCamelCase. I switched it to LowerCamelCase and everything now works.

    ex. Private String CustName; changed to Private String custName;