jpa 本地查询 获取部分字段值

 query = entityManager.createNativeQuery("select studentType,stata from SchoolStructure where unitid = :unitID");
                    query.setParameter("unitID",unitId);
                    List list = query.getResultList();
                    String stuType = "";
                    String stuState = "";
                    if(list.size()>0){
                        Object[] objects = (Object[])list.get(0);
                        stuType = objects[0].toString();
                        stuState = objects[1].toString();
                    }

你可能感兴趣的:(java)