1
HQLクエリ結果の名前とIDをHashmapに保存します。ここに私のコードです。それを行うための良い方法はありますか?Hibernateのクエリ結果をハッシュマップに保存
String hql = "FROM Student";
Session session = HibernateUtil.getSessionFactory().openSession();
Query query = session.createQuery(hql);
List queryResults = query.list();
List<Student> result = new ArrayList<Student>();
Iterator it = queryResults.iterator();
while (it.hasNext()) {
Student student = (Student) it.next();
result.add(student);
}
Map mapresult = new LinkedHashMap<Integer,String>();
for (Student Maprslt : result)
mapresult.put(Maprslt.getId(), Maprslt.getName());
私の質問を見ることができますhttp://stackoverflow.com/questions/38132958/populate-select-dropdownlist-in-spring-mvc – ustaad