问题
I'm using spring-data-neo4j
and I'm trying to combine repositories to be able to use custom ones. I think I've followed correctly the nomenclature conventions specified in 20.8.7 Creating repositories and other SO questions like this.
Anyway, I'm doing something wrong because I'm getting this
exception message
Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property someCriteria found for type User!
User entity
@NodeEntity
public class User {
@GraphId
private Long nodeId;
@Indexed
String mail;
...
}
Repositories (all in the same package)
@Repository
public interface UserRepository extends GraphRepository<User>, UserRepositoryCustom {
User findByMail(String mail);
}
public interface UserRepositoryCustom {
String findBySomeCriteria(String criteria);
}
public class UserRespositoryImpl implements UserRepositoryCustom {
@Override
public String findBySomeCriteria(String criteria) {
return "result";
}
}
services
@Service
public class UserServiceImpl implements UserService {
@Autowired
UserRepository userRepository;
}
Neo4j configuration
<bean id="graphDatabaseService" class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
...
</bean>
<neo4j:repositories base-package="com.mypackage.api.user.repository"/>
<bean id="userService" class="com.mypackage.api.user.service.UserServiceImpl"/>
回答1:
In this case it has been just a stupid spelling
mistake.
Need change UserRespositoryImpl
per UserRepositoryImpl
(without 's': note UserRespositoryImpl).
Anyway, I've been struggling with custom repository combination in spring-data-neo4j
and I think it can be a bit confusing. Also I think there are very few good examples online... So, finally I've decided to create a sample project on GitHub
, with a basic example showing how we can do that.
Hope it help other people in the future.
See on GitHub: neo4jCustomRepository
来源:https://stackoverflow.com/questions/29724312/no-property-found-for-type-combining-repositories-spring-data-neo4j