jpa使用sql查询为map结果

    Query query = entityManager
                  .createNativeQuery("select id, name, age from t_user");
    query.unwrap(SQLQuery.class)
               .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); 
	List<Map<String, Object>> itemlist = (List<Map<String, Object>>) query.getResultList();

 

爱编程-编程爱好者经验分享平台

文章评论

  

版权所有 爱编程 © Copyright 2012. w2bc.com. All Rights Reserved.
闽ICP备12017094号-3