我正在写一个模式,其中包括一些被引用的对象。我想知道实际的引用对象的获取是懒惰的还是急切的。
截止到 arangodb-spring-data 3.2.5
引用对象的默认获取应该是急切的,正如你在 @Ref
注释类。
Ref.class
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)