SpringDataGraph findByProperty not working with Neo4J

326 views Asked by At

When I run the code below, a new User with the expected properties is created. (I confirm with Neoclipse after running the test). However, findByPropertyValue fails to retrieve the user. It just returns null. When I debug I find that usrFromDb1 only seems to contain null-values, even those values that I later confirmed were infact saved in the databse! Does anyone have an idea for a solution?

  @Test(enabled = true, groups = {"functest"})
    public void shouldGetUserDetails() throws Exception {
      User user = new User("admin", "secretpw").persist();

      User usrFromDb1 = userRepository.findOne(user.getId());
      assertNotNull(usr1); //succeeds

      User usrFromDb2 = userRepository.findByPropertyValue("username", "admin");
      assertNotNull(usr2); //fails
}

enter image description here

1

There are 1 answers

1
Michael Hunger On BEST ANSWER

Do you have an @Indexed property on your username attribute.

Could you please show your User class?

The user's fields are null in debug b/c in this mapping mode they are handled transparently by AspectJ, if you call user.getUserName() in the debugger this should yield the value.

Also the variable names in your asserts don't match those from your query-results .e.g usrFromDb2 vs. usr2