Spring data page object json response not having reference object info -


i have org entity has fk relation ownergroup entity.

@entity @access(accesstype.field) @table(uniqueconstraints = @uniqueconstraint(columnnames={"appname","appid"})) public class org {      @id     @column(name = "id")     @generatedvalue(strategy = generationtype.identity)      private int id;      /*@genericgenerator(name = "sequence_org_id", strategy = "com.ciphercloud.ae.generators.orgidgenerator")     @generatedvalue(generator = "sequence_org_id")       @column(name="org_id")     private string orgid;*/      @notempty (message = "org username mandatory")     private string username;      @notempty (message = "org password mandatory")     private string password;      private string securitytoken;      @genericgenerator(name = "sequence_app_id", strategy = "com.ciphercloud.ae.generators.appidgenerator")     private string appname;      private string appid;      @notblank (message = "org category should not null or empty")     private string orgcategory;      private string orgsubcategory;      @notblank (message = "org regionid should not null or empty")     private string regionid;      @transient     private int parent_org_id;       @notfound(action = notfoundaction.ignore)     @manytoone     @jsonignore     @joincolumn(name = "parent_org_id")     private org org;      @notblank (message = "org type should not null or empty")     private string orgtype;      @transient     private int ownergroup_id;  @manytoone ( cascade = cascadetype.all)     @joincolumn( name = "ownergroup_id")     private ownergroup ownergroup; 

my repository class looks like

public interface orgrepostiory extends jparepository<org, serializable> {     public list<org> findbyorgtype(@param("orgtype") string orgtype);     public page<org> findbyorgtypein(@param("orgtype") list<string> orgtype, pageable pageable); } 

i have controller class expose them rest , code as

@requestmapping(value = "/search", method = requestmethod.get)     public responseentity<list<org>> testmap(@requestparam multivaluemap<string, string> params) {          system.out.println("params........" + params);          list<org> orgs = orgserviceimpl.search(params);         if (orgs == null || orgs.size()==0) {             throw new resourcenotfoundexception("invalid search criteria ");         } else {             return new responseentity<list<org>>(orgs, httpstatus.ok);         }     }   @requestmapping(value = "/filter/{pagenumber}", method = requestmethod.get)     public responseentity<pagedresources<org.springframework.hateoas.resource<org>>> filter(@pathvariable integer pagenumber, @requestparam hashmap<string, list<string>> params) {          system.out.println("params........" + params);          if(pagenumber <= 0){             pagenumber = 1;         }          page<org> orgs = orgserviceimpl.filter(pagenumber, params);         if (orgs == null || orgs.getsize()==0) {             throw new resourcenotfoundexception("invalid filter criteria ");         } else {             return new responseentity<>( pagedresourceassembler.toresource(orgs), httpstatus.ok);         }     } 

now when test request in rest client the

request = > http://localhost:8080/orgs/filter/1?orgtype=production 

its getting following output.

// response { username: "testdemo8" password: "testpwd1" securitytoken: "testkey1" appname: null appid: null orgcategory: "admin" orgsubcategory: null regionid: "na15" parent_org_id: 0 available: true inductionstatus: null orgtype: "production" ownergroup_id: 0 id: 32 active: false }- - }- _links: { self: { href: "http://localhost:8080/orgs/filter/1?orgtype=production" }- } 

without pagination

request =>   http://localhost:8080/orgs/search?orgtype=production  // response { username: "testdemo8" password: "testpwd1" securitytoken: "testkey1" appname: null appid: null orgcategory: "admin" orgsubcategory: null regionid: "na15" parent_org_id: 0 available: true inductionstatus: null orgtype: "production" ownergroup_id: 0 **ownergroup: { name: "sfdc-ft" description: "4.5 release" id: 1 }-** id: 32 active: false } 

if observe, when page object not used, returning child table data.

but when use pagination, it's not returning child table data.

is thing needs add child table information when use paging?

i debug issue , found join data getting trimmed pagedresourceassembler class using in controller class. replaced

return new responseentity>(orgs, httpstatus.ok)

now getting reference object data expected.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -