java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long

前端 未结 3 1159
鱼传尺愫
鱼传尺愫 2021-01-06 07:00

I want to return number of rows using native sql. But console says me java.math.BigInteger cannot be cast to java.lang.Long. What\'s wrong? This is my method:

3条回答
  •  猫巷女王i
    2021-01-06 07:18

      String query ="select count(*) from tablename";       
      Number count = (Number) sessionFactory.getCurrentSession().createSQLQuery(query).uniqueResult();
      Long value = count.longValue();
    

    I tried this it works well

提交回复
热议问题