ObjectBox: Get objects with specific relations

Expect the two entities Movie and Genre:

@Entity
public class Movie {

@Id
private long id;
private String name;
private ToMany<Genre> genres;

[...]
}

@Entity
public class Genre {

@Id
private long id;
private String name;

[...]
}

We all know how to create a relation and save it:

Movie movie = new Movie();
movie.setTitle("Star Wars");
movie.getGenres().add(new Genre("Sci-Fi");
box.put(movie);

but is there a possibility to query all Movie-objects with a specific Genre? Like

Box<Movie> box = boxStore.boxFor(Movie.class);

Query query = box.query()
  .equal(Genre_.name, "Sci-Fi") // note that I want to query the Movie-Box with Genre-properties
  .build();
List movies = query.find();

My goal is to find all movies with a specific genre in a simple way. Does anyone know how to do it or do I have to query all movies and filter the result on my own? Or do I have to adapt my entities in another way?

Update: I prepared the correct marked answer below to a working example:

    final Genre genreSciFi = genreBox.query().equal(Genre_.name, "Sci-Fi").build().findFirst();

    List<Movie> filteredMovies = movieBox.query().filter(new QueryFilter<Movie>() {
        @Override
        public boolean keep(@NonNull Movie entity) {
            return entity.getGenres().contains(genreSciFi);
        }
    }).build().find();

To make the contains-Method work correctly, override equals-Method in your Genre-Entity:

@Override
public boolean equals(Object obj) {
    return obj instanceof Genre && ((Genre) obj).getId() == id && ((Genre) obj).getName().equals(name);
}

Answer

Unfortunately, this part of the API is not exposed in Java yet. We want to refactor the Query API very soon.

Until this is ready, you can workaround using query filtering. Example using Java/Kotlin-ish code for brevity:

Query query = movieBox.query().filter(movie -> { 
    return genres.contains(genre -> {
        return "Sci-Fi".equals(genre.getName())
    }
}).build()

(Will make it similar in Java with the next update.)