It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,
visit the help center.
Closed 7 years ago.
data-rest and jpa.
I have created one entity with composite keys using @EmbeddedId
and repository extends CrudRepository with findById query param
when I enter the URL
[a link] (http://localhost:8080/data/person/search/findById?findById=1,2&name=abc)
I'm getting error failed to convert string to Long.
Is there any way of converting string to List of Longs using spring JPA?
Please help me.
I was just working on this functionality today, actually.
In the latest snapshot build, there is a new annotation: @ConvertWith
. You put the class name of a Spring Core Converter implementation in that annotation and the exporter will use that converter to turn the String[]
query parameter values into your query method's parameter.
There is an example of how to use it in your Repository in the tests (I'll update the wiki shortly but haven't had a chance yet as the ink isn't even dry yet on these new snapshots :). To pass multiple values in a URL query string, you reference the same name multiple times:
http://localhost:8080/people/search/findById?id=1&id=2&id=3
You can, of course, chose to encode multiple values into a single parameter value (comma-delimited, for instance) and do the conversion in your own converter. You'll still be passed a String[]
to your custom converter no matter what, though.