Sring result = null;
try {
Query query = session.createQuery(
"select P.name from Person P where P.id=?");
query.setParameter(0, id); /**id 为参数**/
Iterator it = query.iterate();
while (it.hasNext()) {
Object obj = (Object) it.next();
result = (obj!=null)?(new String(obj+"")):null;
}
return result;
} catch (Exception e) {
result = null;
throw new Exception("get Person attribute for name error ");
}