解释指南针 @SearchableComponent @SearchableReference

发布于 2024-08-19 09:44:41 字数 462 浏览 2 评论 0原文

两者也用于注释 jpa 实体中的“外键”,对吧?我确实理解@searchablecomponent

假设我们有类别和子类别。在 @searchablecomponent 的情况下,搜索子类别将返回类别。 @searchablereference 怎么样?我无法理解这个?对于 @searchablereference 的情况,搜索子类别仍会返回类别吗?

参考:http://www.opensymphony。 com/compass/versions/0.9.0/html/core-osem-annotations.html

both also used for annotating "foreign key" in jpa entity right? I do understand @searchablecomponent,

let say we have category and subcategory. search subcategory will return category in this case of @searchablecomponent. what about @searchablereference ? i cannot understand this one? for case of @searchablereference, will searching for subcategory still return category ?

ref: http://www.opensymphony.com/compass/versions/0.9.0/html/core-osem-annotations.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高跟鞋的旋律 2024-08-26 09:44:41

这些注释是 Compass API 的一部分,与 JPA(或 Hibernate、数据库等)没有任何关系。不过,概念是相似的。

如果您使用 @SearchableReference 注释 ClassA 的属性,则 Compass 将仅存储引用对象的 ID。它类似于 Hibernate 的“多对一”或 @ManyToOne 关系。

如果您使用@SearchableComponent,那么Compass在将引用对象存储在compass中时将“内联”所引用对象的所有属性,类似于Hibernate的或<代码>@Embedded。

与 Hibernate/JPA 非常相似,这就是术语的来源。

These annotations are part of the compass API, and have nothing whatsoever to do with JPA (or Hibernate, databases, etc). The concepts are similar, though.

If you annotate a property of ClassA with @SearchableReference, then Compass will store only the referred object's ID. It's similar to Hibernate's "many-to-one" or @ManyToOne relationship.

If you use @SearchableComponent, then Compass will "inline" all of the properties of the referred object when it stores it in compass, similar to Hibernate's <component> or @Embedded.

The similarity with Hibernate/JPA is strong, and it's where the terminology comes from.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文