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.