我正在编写一个包含一些引用对象的架构。我正在尝试了解所引用对象的实际获取是延迟还是渴望。
答案 0 :(得分:0)
自arangodb-spring-data 3.2.5
注释类开始,您应该急于从@Ref
开始默认获取引用对象。
引用类
package com.arangodb.springframework.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.data.annotation.Reference;
/**
* Annotation to indicate that the annotated field is stored as a document in
* another collection instead of a nested document. The document {@literal _id}
* of that document is stored as a reference in the stored field.
*
* @author Mark Vollmary
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
@Reference
public @interface Ref {
/**
* Whether the entity should be loaded lazily
*/
boolean lazy() default false;
}
要使引用的数据加载延迟,您应使用
对其进行注释@Ref(lazy = true)