梦一场丶 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不能转化为数值

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

报告相同问题?

悬赏问题

  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Matlab求解微分方程,如何用fish2d进行预优?