我试图将Hibernate搜索索引设置为以下关系:
DocVersion *<-> Document2 -> DocType
@Indexed
@Entity
public class Document2 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "doc_uuid")
private long id;
@IndexedEmbedded
@ManyToOne(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
@JoinColumn(name = "documentType")
private DocType docType;
}
@Indexed
@Entity
public class DocType implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "doctype_id")
private long id;
@Field
@Column(name = "documentType")
private String documentType;
}所以它是来自Document2类的统一Document2关系,因为DocType只是一个可编码的。
但是,我需要根据cdt的属性(如document2.docType.documentType )查询索引,这给了我:
WARNING: org.hibernate.search.exception.SearchException: Unable to find field document2.docType.documentType in com.nws.vedica.model.entity.DocVersion我遗漏了什么?
hibernate-搜索:5.9.3最后
发布于 2018-11-23 15:38:49
因此,我错过了@ContainedIn,这需要在@IndexedEmbedded的另一边。在Document2对我来说
@ContainedIn
@OneToMany(mappedBy = "document2", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@org.hibernate.annotations.Cache(
usage = CacheConcurrencyStrategy.READ_WRITE
)
private Set<DocVersion> docVersions;而在DocType中,作为一个“叶子”,根本不需要链接到Document2。
希望这对某人有帮助
https://stackoverflow.com/questions/53447967
复制相似问题