Based on the Spring Data Document documentation, I have provided a custom implementation of a repository method. The custom method's name refers to a property which doesn't exist in the domain object:
@Document
public class User {
String username;
}
public interface UserRepositoryCustom {
public User findByNonExistentProperty(String arg);
}
public class UserRepositoryCustomImpl implements UserRepositoryCustom {
@Override
public User findByNonExistentProperty(String arg) {
return /*perform query*/;
}
}
public interface UserRepository
extends CrudRepository<?, ?>, UserRepositoryCustom {
public User findByUsername(String username);
}
However, perhaps because of the method name I've chosen (findByNonExistentPropertyName
), Spring Data attempts to parse the method name, and create a query from it. When it can't find the nonExistentProperty
in User
, an exception is thrown.
Possible resolutions:
- Have I made a mistake in how I provide the implementation of the custom method?
- Is there a way to instruct Spring to not attempt to generate a query based on this method's name?
- Do I just have to avoid using any of the prefixes that Spring Data recognizes?
- None of the above.
Thank you!