mySQL 延迟 查询主表


例:
复制代码 代码如下:

<hibernate-mapping>
<class name="com.pojo.Sortp" table="sortp" catalog="shjdc">
<id name="id" type="java.lang.Integer">
<column name="Id" />
<generator class="assigned" />
</id>
<property name="name" type="java.lang.String">
<column name="Name" length="40" not-null="true" />
</property>
<set name="productses" inverse="true" cascade="all" lazy="true">
<key>
<column name="Sortid" not-null="true" />
</key>
<one-to-many class="com.pojo.Products" />
</set>
</class>
</hibernate-mapping>

一般情况下就是把lazy设为true,而不是false,因为,假如设为false的话,在执行查询主表的同时,相应的子表也会查询,添加了许多无用功。
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3