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

VenueProjection with List<ContactProjection> returns List<Contact> instead [DATAREST-477] #856

Closed
spring-projects-issues opened this issue Feb 16, 2015 · 4 comments
Assignees
Labels
status: duplicate type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Feb 16, 2015

Mirco Andreon opened DATAREST-477 and commented

I have 2 entities that are exposed by Spring Data REST: Venue and Contact. A Venue can have multiple Contacts.
I create this projections:

@Projection(name="details", types = Venue.class)
public interface VenueDetails {
    int getId();
    String getName();
	//...
    List<ContactDetails> getContacts();
}
@Projection(name="details", types = Contact.class)
public interface ContactDetails {
    int getId();
    String getContact();
    ContactType getContact_type();
}

When the client invokes http://localhost:8080/myrestservice/rest/venues/2?projection=details gets:

{
  "id" : 2,
  "name" : "A place in the desert",
  "contacts" : [ {
    "id" : 1,
    "contact" : "555 768547",
  }, {
    "id" : 2,
    "contact" : "contacts@example.org",
  }],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/myrestservice/rest/venues/2{?projection}",
      "templated" : true
    },
    "contacts" : {
      "href" : "http://localhost:8080/myrestservice/rest/venues/2/contacts"
    }
  }
}

You see that every contact misses "contact_type".
But "contact_type" is shown when invoking http://localhost:8080/myrestservice/rest/contacts/1?projection=details:

{
  "id" : 1,
  "contact" : "555 768547",
  "contact_type" : {
    "code" : "T",
    "name" : "Telephone"
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/myrestservice/rest/contacts/1{?projection}",
      "templated" : true
    },
    "contact_type" : {
      "href" : "http://localhost:8080/myrestservice/rest/contacts/1/contact_type"
    },
    "venue" : {
      "href" : "http://localhost:8080/myrestservice/rest/contacts/1/venue"
    }
  }
}

So it seems that expressing List<AProjectionOfALinkedObject> in a projection, ignores AProjectionOfALinkedObject and simply uses ALinkedObject.


Affects: 2.2.1 (Evans SR1)

Issue Links:

  • DATAREST-408 Nested projections not loading nested lists
    ("duplicates")
@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 16, 2015

Oliver Drotbohm commented

That seems to be a duplicate of DATAREST-408 which has been fixed in 2.2.2. Would you mind upgrading and seeing whether this is still an issue?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 16, 2015

Mirco Andreon commented

Thanks Oliver, you are right!
I'm using Spring Boot and in the latest version (1.2.1) Spring Data REST is 2.2.1, but I solved adding dependancies on spring-data-rest-webmvc and -core 2.2.2. I'll wait for the next Spring Boot release.
Thank you very much

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 16, 2015

Oliver Drotbohm commented

You can simplify the setup by just overriding the spring-data-releasetrain.version property to Evans-SR2. This will make sure all necessary Spring Data modules get updated to the matching versions

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 16, 2015

Mirco Andreon commented

Great suggestion! I started using it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate type: bug
Projects
None yet
Development

No branches or pull requests

2 participants