use of org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils.reference in project hibernate-search by hibernate.
the class SearchQueryBaseIT method select_compositeAndLoading.
@Test
public void select_compositeAndLoading() {
setupHolder.runInTransaction(session -> {
SearchSession searchSession = Search.session(session);
SearchQuery<Book_Author_Score> query = searchSession.search(Book.class).select(f -> f.composite().from(f.composite().from(f.entity(), f.field("author.name", String.class)).as(Book_Author::new), f.score()).as(Book_Author_Score::new)).where(f -> f.matchAll()).toQuery();
backendMock.expectSearchProjection(Book.NAME, StubSearchWorkBehavior.of(3L, Arrays.asList(Arrays.asList(StubBackendUtils.reference(Book.NAME, "1"), AUTHOR_4_3_2_1), 4.0F), Arrays.asList(Arrays.asList(StubBackendUtils.reference(Book.NAME, "2"), AUTHOR_CIDER_HOUSE), 5.0F), Arrays.asList(Arrays.asList(StubBackendUtils.reference(Book.NAME, "3"), AUTHOR_AVENUE_OF_MYSTERIES), 6.0F)));
assertThat(query.fetchAllHits()).containsExactlyInAnyOrder(new Book_Author_Score(new Book_Author(session.getReference(Book.class, 1), AUTHOR_4_3_2_1), 4.0F), new Book_Author_Score(new Book_Author(session.getReference(Book.class, 2), AUTHOR_CIDER_HOUSE), 5.0F), new Book_Author_Score(new Book_Author(session.getReference(Book.class, 3), AUTHOR_AVENUE_OF_MYSTERIES), 6.0F));
});
}
use of org.hibernate.search.util.impl.integrationtest.common.stub.backend.StubBackendUtils.reference in project hibernate-search by hibernate.
the class SearchQueryBaseIT method select_lambda.
@Test
public void select_lambda() {
setupHolder.runInTransaction(session -> {
SearchSession searchSession = Search.session(session);
SearchQuery<Book_Author_Score> query = searchSession.search(Book.class).select(f -> f.composite().from(f.composite().from(f.entity(), f.field("author.name", String.class)).as(Book_Author::new), f.score()).as(Book_Author_Score::new)).where(f -> f.matchAll()).toQuery();
backendMock.expectSearchProjection(Book.NAME, StubSearchWorkBehavior.of(3L, Arrays.asList(Arrays.asList(StubBackendUtils.reference(Book.NAME, "1"), AUTHOR_4_3_2_1), 4.0F), Arrays.asList(Arrays.asList(StubBackendUtils.reference(Book.NAME, "2"), AUTHOR_CIDER_HOUSE), 5.0F), Arrays.asList(Arrays.asList(StubBackendUtils.reference(Book.NAME, "3"), AUTHOR_AVENUE_OF_MYSTERIES), 6.0F)));
assertThat(query.fetchAllHits()).containsExactlyInAnyOrder(new Book_Author_Score(new Book_Author(session.get(Book.class, 1), AUTHOR_4_3_2_1), 4.0F), new Book_Author_Score(new Book_Author(session.get(Book.class, 2), AUTHOR_CIDER_HOUSE), 5.0F), new Book_Author_Score(new Book_Author(session.get(Book.class, 3), AUTHOR_AVENUE_OF_MYSTERIES), 6.0F));
});
}
Aggregations