2

I have the following problem. I am currently working with spring, spring-data-jpa and spring-data-rest. I want to create an rest endpoint for my jpa repository.

So, my current response of my spring-data-rest endpoint is as follows:

{
  "_embedded": {
    "game": [
      
    ]
  },
  "_links": {
    "self": {
      "href": "http://localhost:8080/game"
    },
    "profile": {
      "href": "http://localhost:8080/profile/game"
    }
  },
  "page": {
    "size": 20,
    "totalElements": 0,
    "totalPages": 0,
    "number": 0
  }
}

My problem is, that I only want to return the game part in the _embedded part. No _links, no other things. How can I do that?

Dominic
  • 70
  • 1
  • 7

1 Answers1

0

Does that answer your question?

You can use projection, Spring Data REST documentation:

But what if you do not want address details at all? Again, by default, Spring Data REST exports all of its attributes (except the id). You can offer the consumer of your REST service an alternative by defining one or more projections.

pholak
  • 158
  • 1
  • 8