我有一個數據庫,它類似於以下內容:iBatis的如何解決更復雜的N + 1個問題
create table Store(storeId)
create table Staff(storeId_fk, staff_id, staffName)
create table Item(storeId_fk, itme_id, itemName)
Store表大。
而且我已創建了以下Java bean的
public class Store
{
List<Staff> myStaff
List<Item> myItem
....
}
public class Staff
{
...
}
public class Item
{
...
}
我的問題是如何使用iBATIS的結果地圖有效地從表到Java對象映射?
我想:
<resultMap id="storemap" class="my.example.Store">
<result property="myStaff" resultMap="staffMap"/>
<result property="myItem" result="itemMap"/>
</resultMap>
(other maps omitted)
但它太慢,因爲Store表是非常非常大的。
我試圖按照克林頓的開發者指南爲N + 1個解決方案的例子,但我不能彎曲我的腦海裏圍繞着如何與2列表中使用的「GROUPBY」的對象...
任何幫助感謝!
感謝您的建議,我重新考慮了我的問題,並針對我的問題提出了不同的方法,它幾乎與您的建議保持一致。我試圖讓我們把iBatis當作休眠,但我錯了! – Alvin 2010-06-08 08:09:09