[英]Hibernate lazy property fetching configuration
我需要使用Hibernate延遲加載實體屬性(圖像文件),但是我不了解其所需的配置。
根據https://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#performance-fetching-lazyproperties,我需要設置字節碼檢測工具來延遲加載屬性。
<taskdef name="instrument" classname="org.hibernate.tool.instrument.InstrumentTask">
<classpath path="${jar.path}"/>
<classpath path="${classes.dir}"/>
<classpath refxml:id="lib.class.path"/>
</taskdef>
<instrument verbose="true">
<fileset dir="${testclasses.dir}/org/hibernate/auction/model">
<include name="*.class"/>
</fileset>
</instrument>
</target>
我不明白我必須給“ lib.class.path”和“ $ {testclasses.dir}”指定什么路徑。
您可以使用注釋來指定要針對該特定參數的提取類型。
@Entity
@Table(name = "USER")
public class UserLazy implements Serializable {
@Id
@GeneratedValue
@Column(name = "USER_ID")
private Long userId;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
private Set<OrderDetail> orderDetail = new HashSet();
// standard setters and getters
// also override equals and hashcode
}
這也是一些額外的解釋: https : //howtodoinjava.com/hibernate/lazy-loading-in-hibernate/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.