25
06/19
JAP使用createNativeQuery做原始的字段映射处理
//方法一: publicvoid testNativeQuery(){ Query query = entityManager.createNativeQuery("select id, name, age from t_user"); query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); List rows = query.getResultList(); for(Object obj : rows){ Map row =(Map) obj; System.out.println("id = "+ row.get("ID")); System.out.println("name = "+ row.get("NAME")); System.out.println("age = "+ row.get("AGE")); } } //方法二: @PersistenceContext pr...