2

I run an SDR application based on the Spring Boot Gradle Plugin. I recently upgraded from 2.1.9.RELEASE to 2.2.0.RELEASE. Without being 100% sure that this was the very reason, SDR now seems to expose an additional _embedded field for every resource. The new field contains data of related entities.

As an example, this is a resource exposed with 2.1.9.RELEASE:

{
  "uuid": "77315176-cb4f-4126-8e8b-9007457a7ce1",
  "name": "root",
  "_links": {
    "self": {
      "href": "localhost/users/1"
    },
    "user": {
      "href": "localhost/users/1"
    },
    "group": {
      "href": "localhost/users/1/group"
    }
  }
}

The same resource exposed with 2.2.0.RELEASE:

{
  "uuid": "77315176-cb4f-4126-8e8b-9007457a7ce1",
  "name": "root",
  "_embedded": {
    "group": {
      "uuid": "be43382c-7b03-4d28-9597-7284986f700b",
      "name": "admin"
    }
  },
  "_links": {
    "self": {
      "href": "localhost/users/1"
    },
    "user": {
      "href": "localhost/users/1"
    },
    "group": {
      "href": "localhost/users/1/group"
    }
  }
}

Without a proof, I assume the following downsides:

  1. It increases the response size considerably. I can understand that there are use cases in which this additional data is desired, however, in such cases I prefer exposing it manually by crafting Projections as needed.
  2. In order to collect the additionally exposed data, additional database transactions are required, which negatively impacts performance.
  3. More public API is exposed by default, which one has to maintain. Again, I'd prefer to make use of Projections in order to minimize the response if possible.

This are my questions:

  1. Is it possible to restore the previous API format, e.g. customizing the new feature or by turning it off completely?
  2. I wonder what was the design desicion for this. Given the above-assumed downsides, which advantages come with the new feature?
aboger
  • 2,214
  • 6
  • 33
  • 47
  • Please include the user and userRepository classes too. – Selindek Oct 26 '19 at 21:24
  • 1
    Is your issue the same as this one a couple of weeks ago and for which a bug report was created? https://stackoverflow.com/questions/58213756/associated-resources-are-embedded-after-upgrading-dependency – Alan Hay Oct 27 '19 at 09:00
  • I cannot post `user` and `userRepository`, as they don't exist. I posted some sample data to point out the issue. I thought about crafting and posting the missing classes, but I think it's no longer necessary, as @AlanHay already come up with a great direction. – aboger Oct 27 '19 at 10:09
  • @AlanHay, please post an answer with a link to the JIRA ticket so I can accept it, or we can also close this question as a duplicate. – aboger Oct 27 '19 at 10:13

1 Answers1

1

It turned out to be Spring Data Rest bug. Version 2.2.1.RELEASE contains a fix, which restores the usual behaviour.

aboger
  • 2,214
  • 6
  • 33
  • 47