查询单向多对一索引
query unidirectional many2one index
我正在尝试使 Hibernate Search 索引具有以下关系:
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 class 的单向 @ManyToOne
关系,因为 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
我错过了什么?
休眠搜索:5.9.3.Final
所以我错过了需要在 @IndexedEmbedded
对面的 @ContainedIn
。对我来说 Document2
:
@ContainedIn
@OneToMany(mappedBy = "document2", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@org.hibernate.annotations.Cache(
usage = CacheConcurrencyStrategy.READ_WRITE
)
private Set<DocVersion> docVersions;
并且在 DocType
中作为 'leaf' 根本不需要 link 回到 Document2
。
希望对某人有所帮助
我正在尝试使 Hibernate Search 索引具有以下关系:
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 class 的单向 @ManyToOne
关系,因为 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
我错过了什么?
休眠搜索:5.9.3.Final
所以我错过了需要在 @IndexedEmbedded
对面的 @ContainedIn
。对我来说 Document2
:
@ContainedIn
@OneToMany(mappedBy = "document2", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@org.hibernate.annotations.Cache(
usage = CacheConcurrencyStrategy.READ_WRITE
)
private Set<DocVersion> docVersions;
并且在 DocType
中作为 'leaf' 根本不需要 link 回到 Document2
。
希望对某人有所帮助