0
FullTextQuery.setProjection(「id」,「author」)忽略了作者的id,name屬性。我如何檢索這些屬性?如何檢索@IndexedEmbedded屬性?
@MappedSuperclass
class BaseContent{
@IndexedEmbedded(prefix = "author.", includePaths = {"id", "name"}) @ManyToOne
Author author;
}
@Entity @Indexed
class Content extends BaseContent{
@Id @DocumentId
Integer id;
}
@Entity
class Author{
@Id
Integer id;
@Field(store = Store.YES)
String name;
}
編輯: 這是正確的查詢?
FullTextQuery ftq = fullTextSession.createFullTextQuery(luceneQuery, Content.class);
ftq.setProjection("id", "author.id", "author.name");
ftq.setResultTransformer(new AliasToBeanResultTransformer(Content.class));
List<Content> result = ftq.list();
默認前綴正確存儲。正確搜索。但爲什麼不能檢索它? – hurelhuyag
@hurelhuyag您的示例在調用'setProjection'時不使用前綴...您能否爲我們提供用於搜索的確切代碼,從構建完整查詢到調用結果查詢中的「list()」? –
我編輯的問題。 – hurelhuyag