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

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不能转化为数值

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

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题