我使用hibernate和jsp-servlet。當我試圖訪問子元素屬性時,我收到以下異常:Hibernate org.hibernate.LazyInitializationException
Servlet.service() for servlet jsp threw exception: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.ecomm.ultimatesms.messaging.persistence.pojos.Mno.startnumbers, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380) [:3.3.2.GA]
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372) [:3.3.2.GA]
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365) [:3.3.2.GA]
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108) [:3.3.2.GA]
這是我的hibernate映射文件。我使用hibernate-mapping
default-lazy="false"
<hibernate-mapping default-lazy="false">
<class name="com.ecomm.ultimatesms.messaging.persistence.pojos.Mno" table="mno" schema="public">
<id name="pkmnoid" type="long">
<column name="pkmnoid" />
<generator class="sequence">
<param name="sequence">mno_pkmnoid_seq1</param>
</generator>
</id>
<property name="name" type="string">
<column name="name" length="45" />
</property>
<set name="startnumbers" table="startnumber" inverse="false" lazy="true" fetch="select" cascade="delete">
<key>
<column name="fkmnoid" />
</key>
<one-to-many class="com.ecomm.ultimatesms.messaging.persistence.pojos.Startnumber" />
</set>
</class>
</hibernate-mapping>