这是我第二次和jpa一起玩,
我写了这段代码:
String queryString = "SELECT e.uidprofile, e.profilecode, e.catUso, max(e.zonaClim), e.classePrev, e.beta1, e.beta2, e.beta3, e.beta4"
+ " FROM "
+ entityClass.getSimpleName()
+ " e "
+ " WHERE e.catUso like :code "
+ " group by e.uidprofile, e.profilecode, e.catUso, e.classePrev, e.beta1, e.beta2, e.beta3, e.beta4"
+ " order by e.uidprofile";
Query query = entityManager.createQuery(queryString);
query.setParameter("code", "C" + "%");
List<SamTbProfileMapping> resultList = query.getResultList();
ClassLoader c1 = this.getClass().getClassLoader();
ClassLoader c2 = resultList.getClass().getClassLoader();
if(resultList.size()>0){
System.out.println(resultList.get(0).getCatUso());
}
调试它:
resultList
SamTbProfileMapping
具有正确值的所有字段- 对象的数量是正确的
- 在
List<SamTbProfileMapping> resultList = query.getResultList();
我到达C2
并null
说System.out.println(resultList.get(0).getCatUso());
resultList 不能被投射到之后SamTbProfileMapping