0
我有User
到Cars
1對n。 映射:休眠:目標虛擬機發生異常:未能延遲初始化集合
用戶:
<set inverse="true" name="cars" table="CAR">
<key>
<column name="UserID" not-null="false"/>
</key>
<one-to-many class="entity3.Car"/>
</set>
汽車:
<many-to-one class="entity3.User" name="user">
<column name="UserID" not-null="false"/>
</many-to-one>
後,我得到一些用戶關閉會話,調試器,在user
我看到PersistentSet cars
與此異常的價值:
>Exception occurred in target VM: failed to lazily initialize a collection of role: entity3.User.cars, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: entity3.User.cars, no session or session was closed
這是正常行爲嗎?那些例外會減慢性能嗎?