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