When using a RepositoryRestConfigurer with an Entity Lookup to customise the id part of URI, not all methods work as expected.
In the linked github repo, I've created a project which demonstrates the issue. In it, I've got a User entity which uses a Generated id as the primary key, but uses the userName as a natural key.
{
"cause": {
"cause": null,
"message": "For input string: \"DAVIDM\""
},
"message": "Failed to convert from type [java.lang.String] to type [long] for value 'DAVIDM'; nested exception is java.lang.NumberFormatException: For input string: \"DAVIDM\""
}
If I use the internally generated primary key, it works:
Would you mind trying the Moore snapshots? We've just recently tweaked stuff in this area for DATAREST-1304. Unfortunately we cannot port this back as the fix requires new API introduced for Moore in Spring Data Commons
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
spring-projects-issues commentedJun 27, 2019
davidm76 opened DATAREST-1405 and commented
When using a RepositoryRestConfigurer with an Entity Lookup to customise the id part of URI, not all methods work as expected.
In the linked github repo, I've created a project which demonstrates the issue. In it, I've got a User entity which uses a Generated id as the primary key, but uses the userName as a natural key.
I've added a RepositoryRestConfigurer like this:
This allows me to create a new record like this:
Curl:
I get the following good response, with the userId in the self reference:
I can do a get using the userName:
response:
However, if I try and update the full name with a PUT:
I get the following response:
If I use the internally generated primary key, it works:
Response:
I can do the delete using the username:
It seems like all methods work as expected with the exception of the PUT.
Thanks.
Affects: 3.1.9 (Lovelace SR9)
Reference URL: https://github.com/davidm76/spring-data-rest-issue
Issue Links:
The text was updated successfully, but these errors were encountered: