首页 > 编程语言 >cannot be cast to java.util.Map

cannot be cast to java.util.Map

时间:2022-09-22 18:45:16浏览次数:45  
标签:Map java util cast cannot query

特别记一下,对象的字段,首字母小写!!!

代码:

@Override
    public List<MODEL_Vo> find(String str) {
        String sql="select * from tab  ";
        Query query = em.createNativeQuery(sql);
        query.setParameter("str", str);
//字段名小写开头!
    query.unwrap(SQLQuery.class).setResultTransformer(Transformers.aliasToBean(MODEL_Vo.class));
        List<MODEL_Vo> list = query.getResultList();
        return list;
    }

在使用Transformers.aliasToBean 进行映射时,modelVO必须首字母小写!!!

不然就会报错。而且还是让人很疑惑的错误。cannot be cast to java.util.Map




标签:Map,java,util,cast,cannot,query
From: https://www.cnblogs.com/hanjun0612/p/16720481.html

相关文章