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
ResourceProcessor not used for nested Projection [DATAREST-925] #1288
Comments
Marc Zampetti commented Updated with a more clear description and linked to the demonstration repo |
Craig commented SDR only processes ResourceProcessor's for PersistentEntityResource. I believe it should process ResourceProcessor's for ProjectionResource's too. I think the change needs to be made at https://github.com/spring-projects/spring-data-rest/blob/2.5.3.RELEASE/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java#L580 and https://github.com/spring-projects/spring-data-rest/blob/2.5.3.RELEASE/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java#L185 to call invoker.invokeProcessorsFor as is currently done at https://github.com/spring-projects/spring-data-rest/blob/2.5.3.RELEASE/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityJackson2Module.java#L390 |
Oliver Drotbohm commented What I am kind of wondering is: is the fact that you have a |
Craig commented I believe the best solution is to get ResourceProcessor instances invoked that are explicitly typed to the projection. If someone wants a ResourceProcessor to apply to both the entity and the projection, they can create an interface that both the entity and the projection extend and create a ResourceProcessor for that |
Craig commented I ran the test case https://github.com/zampettim/datarest925 against my pull request at #238 by adding this to the pom.xml of test case: <dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>2.5.5.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-core</artifactId>
<version>2.5.5.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
<version>2.5.5.BUILD-SNAPSHOT</version>
</dependency> Here's the last curl execution's output from the issue's description:
Notice that the embedded Person has the "google" links as it should |
Oliver Drotbohm commented That's fine. We still need an integration test for our codebase |
Johannes Hiemer commented This is something I asked Oliver a couple of weeks ago as well. Would be nice to see this feature in the implementation! |
Oliver Drotbohm commented That's in place now. I've merged Craig's PR so that |
Marc Zampetti opened DATAREST-925 and commented
There seems to be an issue with how ResourceProcessors are being applied to a Projection in certain case. I've linked to a repo that demonstrates the issue.
There are two entities,
Person
andAddress
. ThePerson
is the parent in a@ManyToOne
relationship to theAddress
. There is also aPersonProjection
that shows a subset of thePerson
, most importantly it does not include theSet<Address>
of the childAddress
entities. There is also aAddressProjection
that includes thePersonProjection
of the parent. The goal is to be able to retrieve the list ofAddress
objects and their associated keyPerson
information in a single call.Now, I also have
ResourceProcessor
implementations that add some links to each of the entities. That includesResourceProcessor
implementations on the projections. Everything works as described and expected when using the normal SDR endpoints to get thePerson
andAddress
collections. The custom links are correctly added to each entity. Also, when I query for thePerson
collection with the projection, that too adds the appropriate link to thePerson
representation. However, when I query theAddress
collection with the projection, the embeddedPersonProjection
has the normal SDR-generated links forself
and the object itselfperson
in this case, it does not have the custom links.The listing of the
Person
collection. Notice thegoogle
link, which is the custom link for this demonstration:Now the listing of the
Person
collection with the projection enabled. Notice that thequote
field is not returned, but thegoogle
link is still there.The listing of the
Address
collection. Notice themicrosoft
link which is the custom link for this demonstration:And finally the listing of the
Address
projection, without the expectedgoogle
link for the embeddedPerson
. However, thePerson
is missing thequote
field, so it is processing the rest of the projection.It is not clear why the additional links are not being added. For all I can tell, it should be. There are no errors or warnings or any other indication of an issue that I can see.
Affects: 2.5.4 (Hopper SR4)
Reference URL: https://github.com/zampettim/datarest925
Referenced from: pull request #238
Backported to: 2.6 RC1 (Ingalls)
2 votes, 4 watchers
The text was updated successfully, but these errors were encountered: