Hibernate 默认支持延迟获取,除非 exlplicity 将其设置为 Eager fetching。如果您想了解有关延迟获取的一些想法,请参阅此
如果是属性laza加载尝试类似
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
>
<class
name="db.hibernateSimple.Copay"
table="EHR_COPAY"
polymorphism="explicit"
>
<id
name="id"
column="COPAY_ID"
type="long"
unsaved-value="null"
>
<generator class="sequence">
<param name="table">HIVAL</param>
<param name="column">NEXT</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Copay.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="balance"
type="int"
column="balance"
length="10"
/>
<property
name="date"
type="java.lang.String"
column="OWNERSHIP_DATE"
/>
<property
name="comments"
type="java.lang.String"
column="comments"
lazy="true"
/>
<many-to-one
name="user"
class="db.hibernateSimple.User"
cascade="none"
outer-join="auto"
column="USER_ID_SEQ"
/>
我从这里提取了上面的内容,我猜你可以得到一些想法