Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Data REST ignoring @JsonUnwrapped annotation #6722

Closed
gjoris opened this issue Aug 23, 2016 · 4 comments
Closed

Spring Data REST ignoring @JsonUnwrapped annotation #6722

gjoris opened this issue Aug 23, 2016 · 4 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@gjoris
Copy link

gjoris commented Aug 23, 2016

Using Spring Boot 1.4.0, Spring Data REST no longer seems to take the @JsonUnwrapped annotation into account to unwrap entities in the JSON responses. The previous Spring Boot versions (i.c. 1.3.7) does not have this problem.

It can be easily reproduced on the master branch of the RestBucks project. When you PUT a payment for an order, the credit card number should be unwrapped, since it is annotated with @JsonUnwrapped, but it is not:

{
  "amount": "EUR4.20",
  "creditCard": {
    "number": {
      "number": "1234123412341234"
    },
    "cardHolderName": "Oliver Gierke",
    "expirationDate": "2099-12-01"
  },
  "_links": {
    "restbucks:order": {
      "href": "http://localhost:8080/orders/1{?projection}",
      "templated": true,
      "title": "An order"
    },
    "curies": [
      {
        "href": "http://localhost:8080/docs/{rel}.html",
        "name": "restbucks",
        "templated": true
      }
    ]
  }
}

The expected output would be (if the @JsonUnwrapped annotation was parsed correctly):

{
  "amount": "EUR4.20",
  "creditCard": {
    "number": "1234123412341234",
    "cardHolderName": "Oliver Gierke",
    "expirationDate": "2099-12-01"
  },
  "_links": {
    "restbucks:order": {
      "href": "http://localhost:8080/orders/1{?projection}",
      "templated": true,
      "title": "An order"
    },
    "curies": [
      {
        "href": "http://localhost:8080/docs/{rel}.html",
        "name": "restbucks",
        "templated": true
      }
    ]
  }
}

We have written tests for the @JsonUnwrapped annotation specifically, not using the Spring Data REST infrastructure, and it does work correctly, which makes us believe that the problem lies somewhere in the framework. I haven't been able to pinpoint where exactly thus far, though.

As said: workaround (for us, at least) at this point is downgrading to 1.3.7.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 23, 2016
@wilkinsona
Copy link
Member

This looks like a Spring Data REST bug. Spring Boot 1.3.x uses Spring Data Gosling and @JsonUnwrapped works as expected. However if spring-data-releasetrain.version is overriden to use Spring Data Hopper @JsonUnwrapped no longer works. You can see this behaviour if you check out and run this commit in RestBucks.

Can you please open a DATAREST Jira ticket?

/cc @olivergierke

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 25, 2016
@polysantiago
Copy link

@gjoris have you created a ticket for this issue? Otherwise, I can do it since it's affecting our project too but I don't want to create a duplicate ticket.

@larsvanherk
Copy link

@polysantiago Hey there, my colleague @gjoris isn't in the office for the next couple of days, but from what he told me about it, he couldn't create an issue ticket in Jira. If you have the possibility to create a ticket, that would be awesome!

@polysantiago
Copy link

polysantiago commented Aug 29, 2016

@larsvanherk I've created DATAREST-880 and linked it to this issue. Hope it's enough information! I'll try to debug and find out where the issue lies so as to make it easier for @olivergierke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

5 participants