cyw521
梦一场丶
2017-04-17 01:29
采纳率: 66.7%
浏览 1.2k

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
    ljheee 2017-04-17 02:18
    已采纳

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

    entname不能转化为数值

    点赞 评论

相关推荐