0
我在我的應用程序這種關係:的Hibernate XML的ArrayList
Entry 1:n Guest
的Entry.class
包含以下屬性:
Entry {
...
List<Guest> guestList = new ArrayList<Guest>();
...
}
我想配置此guestList
屬性在Hibernate中延遲加載,但它不起作用。下面是我有:
<class name="...." table="entry">
<id name="id" column="entry_id" type='long'>
<generator class="native" />
</id>
...other properties...
<list name="guestList" table="guest" cascade="all">
<key column="entry_fk"/>
<index column="guest_id"/>
<one-to-many class="Guest"/>
</list>
...other properties...
</class>
這裏是遊客的表架構的描述:
table : guest[guest_id,entry_fk,guestName,...]
順便說一句...
- 我不能在這個項目中使用註釋。
- 最好,我想使用延遲加載(儘快它的工作)
- 我沒有在我的表中的索引,但Hibernate不斷要求這個定義。
感謝您的意見! 關於1.對不起,在我部署的代碼中,我列出了而不是ArrayList - 我在示例中犯了一個錯誤。 (現在更新) 有沒有人對2有具體的建議? –
ndrizza
2012-07-25 14:02:20
我的回答包含一個建議。添加索引列,或使用'bag'而不是'list'。 – 2012-07-25 14:07:50