如果你个这个sql取得是一条数据的话最好用map
Map result =
getSession().createSQLQuery("SELECT studentId,studentPassword From student WHERE studentId=2014041883;").setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).uniqueResult();
result.get("studentId") and result.get("studentPassword") 就可以获取你想要的值了
如果你是多条的话
List> result =getSession().createSQLQuery("SELECT studentId,studentPassword From student WHERE studentId=2014041883;").setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
for(Map map :result){
map.get("studentId") and map.get("studentPassword") 就可以获取你想要的值了
}