spring data rest query by nested object -


i have spring data rest application using jpa underlying implementation. have data model similar following:

@entity public class person {    @id   private long id;   private string name;    @manytoone   private address address;  }  @entity public class address {    @id   private integer id;   private string street;   private string city;   private string state;   private string zip;    @onetomany(mappedby = 'address')   private list<person> people; } 

i've left out getter/setters, there. have 2 crudrepository interfaces defines access 2 entities. on personrepository, i've defined method findbynameandaddress. intent search people given name , have linked address. problem think i'm supposed pass in id of address in findbynameandaddress query. since i'm doing of via rest client, never have id. when retrieve address entities addressrepository, sdr removes id field json respresentation. according i've read, idea use self link when referring entity.

now, obviously, determine id parsing self link , using in query, seems violating whole hal principal. have suggestions on how 1 supposed this?

ok, figured out how enable this, using custom repositoryrestmvcconfiguration class override config() method , use exposeidsfor() method add in domain classes.

note: using spring boot, , when configured own configuration class, of auto-configured bits spring boot doing, including jackson setup, broke. figured out had extend org.springframework.boot.autoconfigure.data.rest.springbootrepositoryrestmvcconfiguration instead of repositoryrestmvcconfiguration spring data rest.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

c++ - No viable overloaded operator for references a map -

java - UML - How would you draw a try catch in a sequence diagram? -