HibernateSearch学习3
Embedded and associated objects
Using @IndexedEmbedded to index associations
@Entity@Indexedpublic class Place {@Id@GeneratedValue@DocumentIdprivate Long id;@Field( index = Index.TOKENIZED )private String name;@OneToOne( cascade = { CascadeType.PERSIST, CascadeType.REMOVE } )@IndexedEmbeddedprivate Address address;....}@Entitypublic class Address {@Id@GeneratedValueprivate Long id;@Field(index=Index.TOKENIZED)private String street;@Field(index=Index.TOKENIZED)private String city;@IndexedEmbedded(depth = 1, prefix = "ownedBy_")private Owner ownedBy;@ContainedIn@OneToMany(mappedBy="address")private Set<Place> places;...}@Embeddablepublic class Owner {@Field(index = Index.TOKENIZED)private String name;...}