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

Handle fields containing entities that are not exported #2

Open
c-classen opened this issue Oct 12, 2020 · 0 comments
Open

Handle fields containing entities that are not exported #2

c-classen opened this issue Oct 12, 2020 · 0 comments

Comments

@c-classen
Copy link

Spring allows setting the exported attribute of the RepositoryRestResource annotation to false.

If this is done, no HTTP methods are available for the corresponding entity. Also, if that entity B is referenced in another entity A using a relationship, no link is generated for GET responses for A. Instead, there will be a field in the A object containing an object representing B, but that object does not contain an ID field. Therefore, if the entity A returned from a GET request is used for an update, Spring will complain about the missing ID.

If FeGen should allow using entities that are not exported as fields of other entities, this means that the following things should work ("B" stands for an entity that is not exported and "A" stands for an entity that has a field that references B):

  • Create an instance of A referencing an instance of B that is already in the database. In A's field for B, an object containing the ID of B in an "id" field must be sent. This ID must probably be retrieved from a custom endpoint since Spring does not export it by default.
  • Update an instance of A that has been retrieved by a GET request. If the value of B was not null and should not be changed, the ID of B must be added to the object before the PUT. Otherwise, the update will fail. Not sending the B field is not an option since that will set it to null
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

1 participant