[英]Hibernate lazy property fetching configuration
I need to lazy load entity properties (image files) with Hibernate.However I do not understand the configuration required for it. 我需要使用Hibernate延迟加载实体属性(图像文件),但是我不了解其所需的配置。
According to https://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#performance-fetching-lazyproperties I need to setup bytecode instrumentation to lazy load properties. 根据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>
I do not understand what path I have to give to "lib.class.path" and "${testclasses.dir}". 我不明白我必须给“ lib.class.path”和“ $ {testclasses.dir}”指定什么路径。
You can use annotations to specify what type of fetch do you want for that specific parameter. 您可以使用注释来指定要针对该特定参数的提取类型。
@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
}
Here is also some extra explanations: https://howtodoinjava.com/hibernate/lazy-loading-in-hibernate/ 这也是一些额外的解释: https : //howtodoinjava.com/hibernate/lazy-loading-in-hibernate/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.