I'm using Spring Data Neo4J.
I have extended the basic GraphRepository interface, adding a method, as follows:
However, I'm finding that subclasses of this interface don't behave as expected.
When I call UserRepository.findByEntityId(), I expect to get a single instance of UserNode returned, or null.
Instead, I get a scala.collection.JavaConversions$MapWrapper.
However, if I change the UserRepository to specify the type, then everything works (though, defeats the purpose of the baseclass)
Here's a test:
Running this test with the extra line in UserRepository commented out fails. Otherwsie, the test passes.
Is this a bug? Have I written the repo interface correctly?
I have extended the basic GraphRepository interface, adding a method, as follows:
Code:
/**
* Extension to the repository interface for standard Spring Data repo's that
* perform operations on graph entities that have a related RDBMS entity.
*
* @author martypitt
*
* @param <T>
*/
public interface RelatedEntityRepository<T> extends GraphRepository<T>,
RelationshipOperationsRepository<T>,CypherDslRepository<T> {
public T findByEntityId(Long id);
}
Code:
public interface UserRepository extends RelatedEntityRepository<UserNode>{
}
Instead, I get a scala.collection.JavaConversions$MapWrapper.
However, if I change the UserRepository to specify the type, then everything works (though, defeats the purpose of the baseclass)
Code:
public interface UserRepository extends RelatedEntityRepository<UserNode>{
public UserNode findByEntityId(Long id);
}
Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/graph-test-context.xml"})
@Transactional
public class UserRepositoryTests {
@Autowired
private UserRepository userRepository;
// For Bug
@Test
public void canFindByEntityId()
{
UserNode userNode = new UserNode(1L);
userRepository.save(userNode);
UserNode node = userRepository.findByEntityId(1L);
assertThat(node, notNullValue());
assertThat(node, isA(UserNode.class));
}
}
Is this a bug? Have I written the repo interface correctly?