Search code examples
spring-bootspring-dataspring-hateoasspring-repositories

Pagingandsortingrepositrory in spring data , primary key in the entity is not present in the response


I have declared pagingandSortingRepository for a JPA entity and the response to findall() is below

"_embedded" : {
    "assetDashboardCustomers" : [ {
      "utilization" : "80",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/utilbycustomer/Customer01"
        },
        "assetDashboardCustomer" : {
          "href" : "http://localhost:8080/utilbycustomer/Customer01"
        }
      }
    },

I do not want _links and self [HATEOAS] details, but just the plain JSON. What is the property I should set so that I get a plain JSON in the response


Solution

  • The first comment answers your first question - you cannot turn off the links. The second comment answers you 2nd question which is how to have the ID in the JSON body.

    --- By Alan hay in the comments