我在我的应用程序下面的查询:v的Hibernate查询结果
public List getLocation(String id) {
List object = null;
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from Entrancestolocations as EL left join EL.entrances as E left join EL.location as L where L = " + id);
object = (List) q.list();
} catch (Exception e) {
e.printStackTrace();
}
return object;
}
此查询的结果是一个列表。 Entrancestolocations是一个带有外键位置和入口的表格。我不知道如何在不使用索引的情况下访问此列表的元素,因为我不知道我处理的对象类型是什么。实现是搞砸了 - 如何正确地做到这一点?我应该使用哪种对象来存储来自数据库不同表中的数据,以便能够在应用程序中使用它们? 感谢您的帮助!
你的意思是不是列表中的其他对象,如ArrayList或地图? – 2010-08-05 09:34:51
是的。因此,稍后我可以按以下方式使用它:Object.name – Enzomatric 2010-08-05 09:42:54