Source:
<code>public void testSubCollectionPageTotalsWithJoinFilter() { Author author = new Author(); author.setId(1L); Book book = new Book(); book.setId(2); RelationshipImpl relationship = new RelationshipImpl( Author.class, Book.class, BOOKS, author, Arrays.asList(book) ); List<Path.PathElement> publisherNamePath = Arrays.asList( new Path.PathElement(Book.class, Publisher.class, PUBLISHER), new Path.PathElement(Publisher.class, String.class, "name") ); FilterPredicate publisherNamePredicate = new InPredicate( new Path(publisherNamePath), "Pub1"); <START> EntityProjection entityProjection = EntityProjection.builder().type(Book.class).build(); <END> SubCollectionPageTotalsQueryBuilder builder = new SubCollectionPageTotalsQueryBuilder( entityProjection, relationship, dictionary, new TestSessionWrapper()); TestQueryWrapper query = (TestQueryWrapper) builder .withPossibleFilterExpression(Optional.of(publisherNamePredicate)) .build(); String expected = "SELECT COUNT(DISTINCT example_Author_books) " + "FROM example.Author AS example_Author " + "LEFT JOIN example_Author.books example_Author_books " + "LEFT JOIN example_Author_books.publisher example_Author_books_publisher " + "WHERE (example_Author_books_publisher.name IN (:books_publisher_name_XXX) " + "AND example_Author.id IN (:id_XXX))"; String actual = query.getQueryText(); actual = actual.replaceFirst(":books_publisher_name_\\w+", ":books_publisher_name_XXX"); actual = actual.trim().replaceAll(" +", " "); actual = actual.replaceFirst(":id_\\w+", ":id_XXX"); assertEquals(expected, actual); }</code><technical_language>Technically, entity projection filter clause too</technical_language>

Target:
public void testSubCollectionPageTotalsWithJoinFilter() { Author author = new Author(); author.setId(1L); Book book = new Book(); book.setId(2); List<Path.PathElement> publisherNamePath = Arrays.asList( new Path.PathElement(Book.class, Publisher.class, PUBLISHER), new Path.PathElement(Publisher.class, String.class, "name") ); FilterPredicate publisherNamePredicate = new InPredicate( new Path(publisherNamePath), "Pub1"); EntityProjection entityProjection = EntityProjection.builder() .type(Book.class) .filterExpression(publisherNamePredicate) .build(); Relationship relationshipProjection = Relationship.builder().name(BOOKS).projection(entityProjection).build(); RelationshipImpl relationship = new RelationshipImpl( Author.class, author, relationshipProjection ); SubCollectionPageTotalsQueryBuilder builder = new SubCollectionPageTotalsQueryBuilder( relationship, dictionary, new TestSessionWrapper() ); TestQueryWrapper query = (TestQueryWrapper) builder.build(); String expected = "SELECT COUNT(DISTINCT example_Author_books) " + "FROM example.Author AS example_Author " + "LEFT JOIN example_Author.books example_Author_books " + "LEFT JOIN example_Author_books.publisher example_Author_books_publisher " + "WHERE (example_Author_books_publisher.name IN (:books_publisher_name_XXX) " + "AND example_Author.id IN (:id_XXX))"; String actual = query.getQueryText(); actual = actual.replaceFirst(":books_publisher_name_\\w+", ":books_publisher_name_XXX"); actual = actual.trim().replaceAll(" +", " "); actual = actual.replaceFirst(":id_\\w+", ":id_XXX"); assertEquals(expected, actual); }