spring - spring-data-reference (arangodb) 的 @Ref 是否使用了对引用对象的渴望或延迟获取?
问题描述
我正在编写一个包含一些引用对象的模式。我试图了解引用对象的实际获取是惰性的还是急切的。
解决方案
正如您在注释类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)
推荐阅读
- reactjs - 如何在 npm RunKit 上显示渲染的 React 组件?
- reactjs - 将更多图像从 react-native 应用程序上传到 firebase
- php - 使用 Supervisord - Apache 超时
- scala - SBT 总是在 Docker、docker-compose 上下载包/scala 库
- graph - 使用 GNUPlot 来自单个数据集的多个图
- ruby-on-rails - 在 Ruby 中将时间类增加 30 秒到分钟
- python-3.x - 正则表达式匹配与点组合在一起的字符串
- javascript - 如何消除 javascript 中所有分配的字符,如字符串中的 ""、''、{}
- solr - 使用特殊字符“-”搜索在 Apache Solr 中不起作用
- python - django中的for循环检索所有用户而不是一个和M2M字段数据输出