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 fails when trying to save associations #41

Closed
williewheeler opened this issue Oct 14, 2012 · 1 comment
Closed

Spring Data REST fails when trying to save associations #41

williewheeler opened this issue Oct 14, 2012 · 1 comment

Comments

@williewheeler
Copy link

I'm having trouble using Spring Data REST to save associations between entities. I posted the issue on StackOverflow as a question:

http://stackoverflow.com/questions/12879975/spring-data-rest-uri-vs-entity-id

But it may be an enhancement request or a bug, so I'll post it here too.

I read Oliver's comments regarding REST URIs vs entity IDs in issue #13 and his points are well-taken. But this causes a problem when trying to save associations, because Spring Data REST doesn't convert the associated resource's URI into an entity ID, which Spring Data JPA needs to save the association.

The thought is that if I post a resource with some associated resource already linked as part of the representation, then Spring Data REST ought to be able to resolve that on the backend to an association between the two entities involved. Especially if we're talking about a many-to-one relationship. If I have to come along with a subsequent post (see the "Updating relationships" section of https://github.com/SpringSource/spring-data-rest/wiki/JPA-Repository-REST-Exporter), then doesn't that mean that I can't use @NotNull on the association in question? (It looks like the "Updating relationships" documentation might be talking about parent/child relationships.)

@jbrisbin
Copy link
Contributor

Just posted an answer on the SO question.

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

No branches or pull requests

2 participants