How to add custom methods to Spring Data Rest JPA implementation and leverage HATEOS support?

后端 未结 3 1269
心在旅途
心在旅途 2020-12-28 09:03

I have a Spring Data Rest Repository controller that utilizes JPA for the query implementation, and I need to add some custom query methods that cannot be done using the sta

3条回答
  •  礼貌的吻别
    2020-12-28 09:48

    See the latest docs, as the most recent version of SDR has more details on this, and makes it a bit easier. The key is to use the @RepositoryRestController annotation to be able to add additional methods under the /search endpoint, or the @BasePathAwareController annotation if you want to add endpoints to other parts of the url namespace. Then include the PersistentEntityResourceAssembler as a parameter to your controller method, and use that to generate the HAL output if you are returning your entity objects.

提交回复
热议问题