Spring Boot RepositoryRestResource with FeignClient -


i have built 2 spring-boot apps, server side spring-boot micro-service rest resources , client side spring-boot micro-service app consuming hateoas feed using feign clients.

i have 2 entity objects aggregate , gateway, on both sides. gateway inside aggregate object

as long don't have @repositoryrestresource interface gateway object can retrieve gateway object through aggregate, if have annotation can't gateway listed on aggregate object on client side. have noticed because server side hateoas feed adds link gateway on aggregate instead of json structure gateway.

is there anyway can still gateway object aggregate object while having @repositoryrestresource interface gateway object? or there way configure feign client fill gateway object link?

ex.. client http://localhost:9999/aggregates/

with @repositoryrestresource annotation on gatewayrepository

[   {     "id": "a65b4bf7-6ba5-4086-8ca2-783b04322161",     "gateway": null, //<-- gateway null here     ....... 

without @repositoryrestresource annotation on gatewayrepository

[   {     "id": "a65b4bf7-6ba5-4086-8ca2-783b04322161",     "gateway": { //<-- gateway id , properties there on aggregate object       "id": "4a857a7a-2815-454c-a271-65bf56dc6f79",     ....... 

from server http://localhost:8000/aggregates/

with @repositoryrestresource annotation on gatewayrepository

{   "_embedded": {     "aggregates": [       {         "id": "a65b4bf7-6ba5-4086-8ca2-783b04322161",         "_links": {           "self": {             "href": "http://localhost:8000/aggregates/a65b4bf7-6ba5-4086-8ca2-783b04322161"           },           "gateway": { //<-- gateway becomes link here             "href": "http://localhost:8000/aggregates/a65b4bf7-6ba5-4086-8ca2-783b04322161/gateway"           },         ....... 

without @repositoryrestresource annotation on gatewayrepository

  "_embedded": {     "aggregates": [       {         "id": "b5171138-4313-437a-86f5-f70b2b5fcd22",         "gateway": { //<-- gateway id , properties there on aggregate object           "id": "3608726b-b1b1-4bd4-b861-ee2bf5c0cc03",         ....... 

here server side implementation of model objects

@entity class aggregate extends templateobject {     @onetoone(cascade = cascadetype.merge)     private gateway gateway;     ....... }  @entity class gateway extends templateobject {     @notnull     @column(unique = true)     private string name;     ....... } 

and server side rest repositories are

@repositoryrestresource interface gatewayrepository extends jparepository<gateway, string> {     optional<gateway> findbyname(@param("name") string name); }  @repositoryrestresource interface aggregaterepository extends jparepository<aggregate, string> {     optional<aggregate> findbyname(@param("name") string name); } 

(using these rest resources on port 8000)

on client side have same implantation on model dto objects

class gateway extends templateobject {     @notnull     private string name;     ....... }  class aggregate extends templateobject {     private gateway gateway;     ....... } 

and feign clients

@feignclient("billing-service/gateways") interface gatewayservice extends genericservice<gateway> { }  @feignclient("billing-service/aggregates") interface aggregateservice extends genericservice<aggregate> { } 

(using these feign clients on port 9999 client controllers)

thanks in advance help, advice , suggestions appreciated

you may have @ using projections along rest repositories - have here. afterwards have adapt feignclient request paths provide respective projection parameter.


Comments