java - JPA/Spring returning JSON from 2 MySQL tables as nested Objects -


jpa/spring returning json 2 mysql tables nested objects

i'm brand new jpa/spring if atleast point me in right direction extremely helpful!! cheers!

here get:

[{"conid":1,"phone1":"test","tblpeople":   {"pepid":1,"pepaccountidfk":1,"firstname":"testfirst","lastname":"last","title":"title","notes":"notes"}}] 

what want is:

 [{"conid":1,"phone1":"test",  "pepid":1,"pepaccountidfk":1,"firstname":"testfirst","lastname":"last","title":"title","notes":"notes"}] 

java class tblpeoplecontactinfo:

package cms;     @entity public class tblpeoplecontactinfo implements serializable{  private static final long serialversionuid = 1l;  @id private int conid;  @column(name="con_phone_1") private string phone1;    @onetoone(optional=false) @joincolumn( name="con_person_id_fk") private tblpeople tblpeople;   public string getphone1() {     return phone1; }  public void setphone1(string phone1) {     this.phone1 = phone1; }  public tblpeople gettblpeople() {     return tblpeople; }  public void settblpeople(tblpeople tblpeople) {     this.tblpeople = tblpeople; }   public int getconid() {     return conid; }  public void setconid(int conid) {     this.conid = conid; }     public tblpeoplecontactinfo(){  } } 

tblpeople:

@entity public class tblpeople{ @id private int pepid; private int pepaccountidfk; @column(name="pep_first_name") private string firstname; @column(name="pep_last_name") private string lastname; @column(name="pep_title") private string title; @column(name="pep_notes") private string notes;  @onetoone(mappedby="tblpeople") @jsonignore private tblpeoplecontactinfo tblpeoplecontactinfo;   public tblpeoplecontactinfo gettblpeoplecontactinfo() {     return tblpeoplecontactinfo; }   public void settblpeoplecontactinfo(tblpeoplecontactinfo    tblpeoplecontactinfo) {     this.tblpeoplecontactinfo = tblpeoplecontactinfo; }         public int getpepid() {     return pepid; }   public void setpepid(int pepid) {     this.pepid = pepid; }   public int getpepaccountidfk() {     return pepaccountidfk; }   public void setpepaccountidfk(int pepaccountidfk) {     this.pepaccountidfk = pepaccountidfk; }   public string getfirstname() {     return firstname; }   public void setfirstname(string firstname) {     this.firstname = firstname; }   public string getlastname() {     return lastname; }   public void setlastname(string lastname) {     this.lastname = lastname; }   public string gettitle() {     return title; }   public void settitle(string title) {     this.title = title; }   public string getnotes() {     return notes; }   public void setnotes(string notes) {     this.notes = notes; }   public tblpeople() { } 

change class to:-

    @entity     public class tblpeoplecontactinfo implements serializable{       private static final long serialversionuid = 1l;      @id     private int conid;      @column(name="con_phone_1")     private string phone1;         @onetoone(optional=false)      @joincolumn( name="con_person_id_fk")     @jsonignore     private tblpeople tblpeople;      public string getphone1() {          return phone1;     }      public void setphone1(string phone1) {         this.phone1 = phone1;     }        public tblpeople gettblpeople() {         return tblpeople;       }      public void settblpeople(tblpeople tblpeople) {       this.tblpeople = tblpeople;    }           public int getconid() {         return conid;       }    public void setconid(int conid) {        this.conid = conid;    }         public getfirstname(){         return tblpeople.getfirstname();         }        // samething rest of  variables     public tblpeoplecontactinfo(){          }      } 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -