spring-projects / spring-projects/spring-data-rest
RepositoryNotFoundException thrown in the method objectToMapKey for java.lang.Long [DATAREST-148]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Thomas Darimont opened DATAREST-148 and commented
Github Author: ocruz
Github Last-Updated: 2013-02-06T21:31:35Z
This issue was automatically imported from github
Retrieving a map resource of a class repository where the key of the map is of type Long, it fails due to a RepositoryNotFoundException that is thrown in the method objectToMapKey. The following piece of code is always throwing the exception looking for a repository for the class java.lang.Long:
java
protected RepositoryMetadata repositoryMetadataFor(Class<?> domainType) {
for(RepositoryExporter exporter : repositoryExporters) {
RepositoryMetadata repoMeta = exporter.repositoryMetadataFor(domainType);
if(null != repoMeta) {
return repoMeta;
}
}
throw new RepositoryNotFoundException("No repository found for type " + domainType.getName());
}
This method is called in the objectToMapKey method of RestController:
java
if(ClassUtils.isAssignable(obj.getClass(), String.class)) {
key = (String)obj;
} else if(null != (repoMeta = repositoryMetadataFor(obj.getClass()))) {
AttributeMetadata attrMeta = repoMeta.entityMetadata().idAttribute();
String id = attrMeta.get(obj).toString();
key = "@" + buildUri(config.getBaseUri(), repoMeta.name(), id);
} else {
key = conversionService.convert(obj, String.class);
}
The conversionService is never executed
Reference URL: https://api.github.com/repos/SpringSource/spring-data-rest/issues/66
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.