2

This question is probably related to this SO Link "POSTing a @OneToMany sub-resource association in Spring Data REST"

I would like to understand how to do "Post" has many "Comments" idea using a single PostRepository that is exposed using SDR.

How will i add more comments to the existing posts?

The question is when i do not have a CommentRepository, i will not have any "Location url" to send to the Request.

In this case how should i send the new comment or modify an existing comment? Note: CURL command or HAL Browser usage for performing the same will be useful to understand how it works

Community
  • 1
  • 1
gathreya
  • 45
  • 1
  • 9
  • Ok, there should be no problem simple putting/patching the whole posting itself (including the list of comments) but updating a single comment without a comment repository? Don't know about that. – Florian Schaetz May 14 '16 at 15:21
  • Can you provide your entity mapping and the repositories that are in play? – Mathias Dpunkt May 15 '16 at 08:27

1 Answers1

1

I answered a similar question - so you might want to look at this one. I tried to explain the different use cases there in detail.

https://stackoverflow.com/a/34864254/5371736

Does that apply to your usecase

Community
  • 1
  • 1
Mathias Dpunkt
  • 11,594
  • 4
  • 45
  • 70
  • Your answer to the similar question shed a lot of light on my problem statement. However, with the annotation as described the relationship between One and Many is really more like a "many to many" relationship. The solution you have highlighted gave me a good insight into JSON PATCH, I will try to check if the same approach works for that also. – gathreya May 15 '16 at 20:49
  • The "one to many" and "many to many" was just how i was doing the mapping. This does answer my question. Tks! – gathreya May 15 '16 at 22:32