I am using spring -data-rest in my application. I configured repositoryRest using configureRepositoryRestConfiguration
I added the following two lines in this configuration
config.exposeIdsFor(Person.class); config.setDefaultMediaType(MediaType.APPLICATION_JSON_UTF8); config.useHalAsDefaultJsonMediaType(false);
Before adding this configuration, my answer is as follows
{ "_embedded": { "persons": [] }, "_links": { "self": { "href": "http://192.168.2.42:8082/persons/search/findByGroupId?groupId=44" } } }
I can get a list of empty people using RestTemplate, as expected. But after adding the above configuration, I get the following response structure
{ "links": [{ "rel": "self", "href": "http://localhost:8082/persons/search/findByGroupId?groupId=44" }], "content": [{ "collectionValue": true, "relTargetType": "com.myapp.example.domain.Person", "value": [] }] }
with this answer, RestTemplate returns a list of size 1 containing null values ββfor all attributes in my domain.
Can someone help get an empty list with this structure.
I used the following code to get a response from the API:
restTemplate.exchange( url, GET, HttpEntity.EMPTY, parameterizedTypeReference<Resources<Person>>, Collections.emptyMap() );
UPDATE:
Is this a spring-data-rest error. Because somewhere in the code instead of Person , EmbeddedWrapper used as a domain type. After studying the code, I found that "collectionValue" , "relTargetType" and "value" in the JSON response are deserialized from the EmbeddedWrapper class.
Contact: EmbeddedWrappers.java
spring-data-rest spring-hateoas spring-mvc spring-4
Achaius
source share