List <map>应该参数化对泛型类型Map <k,v>的引用

时间:2017-02-11 13:49:44

标签: java jpa eclipselink

为什么我在Eclipse项目中获得此标记?有人可以解释一下吗?或者给我一个解决方法

  • 地图是原始类型。对泛型类型Map的引用应该参数化为
  • 类型安全:List类型的表达式需要未经检查的转换以符合List

public Integer getAgenteId(Integer agente) {

    try {
        String sql = "SELECT id_agente FROM callcenter.agente WHERE agente = ? ";
        EntityManager em = PersistenceUtil.getEntityManager();
        Query q  = em.createNativeQuery(sql);
        q.setHint(QueryHints.RESULT_TYPE, ResultType.Map);
        List<Map> lm = q.getResultList(); // ECLIPSE MARK HERE

        for (Map rs : lm) { // ANOTHER ECLIPSE MARK HERE

            return (Integer)rs.get("id_agente");

        }

        return null;

    } catch (Exception e) {
        logger.error("Erro (GetAgenteId) : " + e.getMessage());
        e.printStackTrace();
    }

    return null;

}

public Integer getAgenteId(Integer agente) { try { String sql = "SELECT id_agente FROM callcenter.agente WHERE agente = ? "; EntityManager em = PersistenceUtil.getEntityManager(); Query q = em.createNativeQuery(sql); q.setHint(QueryHints.RESULT_TYPE, ResultType.Map); List<Map> lm = q.getResultList(); // ECLIPSE MARK HERE for (Map rs : lm) { // ANOTHER ECLIPSE MARK HERE return (Integer)rs.get("id_agente"); } return null; } catch (Exception e) { logger.error("Erro (GetAgenteId) : " + e.getMessage()); e.printStackTrace(); } return null; }

编辑:我不想发出警告,我想修正警告。

0 个答案:

没有答案