我在我的應用程序下面的查詢: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