简体   繁体   中英

explain compass @SearchableComponent @SearchableReference

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM