How to establish relationships between Spring Data REST / Spring HATEOAS based (micro) services?

后端 未结 2 859
梦谈多话
梦谈多话 2021-01-02 18:02

Trying to figure out a pattern for how to handle relationships when using a hypermedia based microservices based on Spring Data Rest or HATEOAS.

If you have service

2条回答
  •  执笔经年
    2021-01-02 18:52

    In my case I can only derive related items from the service itself. My goal is to abstract the related items to the point that any number of services can be related to a service and only need to lookup ID's or links. One thought was an @ElementCollection named related with a join of the entity ID of the service. Then in the @Embedded have a relLink field and a relatedID field. Then in the repository do a findby to find the relLink and relatedID.

    The hope is to keep it abstracted enough to essentially mimic a Many to Many setup.

提交回复
热议问题