There is an @Indexed annotation for fields. We wanted to try this out, and use it to guide the next test. We added @Indexed to the ID field of the Movie class. This field is intended to represent the external ID that will be used in URIs and will be stable across database imports and updates. This time we went with the default GraphRepository (previously Finder) to retrieve the indexed movie.
Example 7.1. Exact Indexing for Movie id
@NodeEntity class Movie { @Indexed int id; String title; int year; } @Autowired DirectGraphRepositoryFactory graphRepositoryFactory; @Test public void persistedMovieShouldBeRetrievableFromGraphDb() { int id = 1; Movie forrestGump = new Movie(id, "Forrest Gump", 1994).persist(); GraphRepository<Movie> movieRepository = graphRepositoryFactory.createGraphRepository(Movie.class); Movie retrievedMovie = movieRepository.findByPropertyValue("id", id); assertEqual("retrieved movie matches persisted one", forrestGump, retrievedMovie); assertEqual("retrieved movie title matches", "Forrest Gump", retrievedMovie.getTitle()); }