How to update a @ManyToOne relationship with Spring Data REST?

后端 未结 1 1821
借酒劲吻你
借酒劲吻你 2021-02-09 00:47

I use Spring Data REST with JPA. I have a User entity that has a many to one relationship with another called AccountStatus modeled in a separate RDBMS table. The JSON represent

相关标签:
1条回答
  • 2021-02-09 01:36

    It really depends if you have an exported repository for AccountState. If you do you can update your account state with a PATCH against /users/{id}:

    {
        "accountState": "http://localhost:8080/accountStates/2"
    }
    

    So you are using the URI of your account state to reference the resource to assign

    0 讨论(0)
提交回复
热议问题