梦一场丶 2017-04-17 01:29 采纳率: 66.7%
浏览 1282
已采纳

hql转换成sql以后频报for input string “xxx”

这是sql写法

    public List<RegMarpripInfo> getAllMarpripInfo(int offset, int length) {
        // List<RegMarpripInfo> entitylist = null;

        String hql = "select new Map( o.id as id ,o.entname as entname ,o.uniscid as uniscid, t.name as enttype, o.regno as regno , o.opscope as opscope, o.regcap as regcap ,i.name as industryco ,o.credit as credit, o.estdate as estdate ) from RegMarpripInfo o,CodeInd i,CodeEnttype t where 1=1 and o.enttype=t.code and o.industryco=i.code ";
        Query query = sessionFactory.getCurrentSession().createQuery(hql);
        query.setFirstResult(offset);
        query.setMaxResults(length);
        return query.list();

    }

这是sql写法的

 public List<RegMarpripInfo> getAllMarpripInfo(int offset, int length) {
        // List<RegMarpripInfo> entitylist = null;

        String sql = "select o.ID as id ,o.ENTNAME as entname ,o.UNISCID as uniscid, t.name as enttype, o.REGNO as regno , o.OPSCOPE as opscope, o.REGCAP as regcap ,i.name as industryco ,o.CREDIT as credit, o.ESTDATE as estdate  from reg_marpripinfo o  "
                + "LEFT JOIN code_indcode i on (i.NAME=o.INDUSTRYCO)  "
                + "LEFT JOIN code_enttype t on (t.CODE=o.ENTTYPE)  where 1=1 ";
        Query query = sessionFactory.getCurrentSession().createSQLQuery(sql);
        query.setFirstResult(offset);
        query.setMaxResults(length);
        return query.list();

    }

因为不太了解注解写hql左连接就转成了sql写法,但是sql写法一直报错for input string,

要展示的列全部报这个错,

 严重: Servlet.service() for servlet springMVC threw exception
java.lang.NumberFormatException: For input string: "entname"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:492)
    at java.lang.Integer.parseInt(Integer.java:527)
    at javax.el.ArrayELResolver.coerce(ArrayELResolver.java:160)
    at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:45)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:123)

项目框架spring mvc hibernate注解 jsp

控制层代码

 Page page = marManager.queryForPage(Integer.valueOf(pageNo), 10);
            request.setAttribute("page", page);
            List<RegMarpripInfo> mar = page.getList();
            request.setAttribute("marList", mar);

页面展示的代码

  • 写回答

1条回答 默认 最新

  • ljheee 2017-04-17 02:18
    关注

    java.lang.NumberFormatException: For input string: "entname"

    entname不能转化为数值

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?