我有一个StudentInfo表,我需要获取表中name列下的所有名称。
谁能帮我在以下功能中纠正我
@Override
public List<StudentRecord> getAllStudentNames(){
Session session = HibernateUtil.getSessionFactory().openSession();
try {
List<StudentRecord> smrList = new ArrayList<StudentRecord>();
String SQL_QUERY = "select smr.studentName from StudentRecord as smr";
Query query = session.createQuery(SQL_QUERY)
smrList = query.list();
} catch (Exception e) {
e.printStackTrace();
} finally {
session.flush();
session.close();
HibernateUtil.getSessionFactory().close();
}
return smrList
}