1

I have two tables employee and bankname. In employee table there is a column bank_name_id which refers the column of bank table.

I have mapped employee bank_name_id with bank bank_name_id with many to one

I'm using spring mvc @RestController while returning it correctly fetch the data from bankname but converting into json its have repeated fetched data

Table 1    Employee Table:
empid empname bank_name_id
1     XXX      1

Table 2    Bankname table
bank_name_id bank_name
1             QQQ

JSON output:

{
    empid:1,
    empname:"xxx",
    bank:{bank_name_id:1,bank_name:QQQ},
    bankname:{bank_name_id:1,bank_name:QQQ}
}

this bankname data is repeated

Predrag Maric
  • 23,938
  • 5
  • 52
  • 68
Sreemat
  • 616
  • 10
  • 28

1 Answers1

1

As per you result it show that you have two variables in emp entity one bank and other bankname so please delete bankname variable from emp entity. and then check otherwise share you code here.

  • actually it is the table name (bankname) in employee pojo empid ,empname,bank only declared.While Spring is converting to json these details are added – Sreemat Nov 05 '15 at 05:26
  • please share your code of employee pojo i am sure you have declared to variables of type bank one is bank and other is bankname that's why above json is shown in result. – Ahmed Nawaz Nov 05 '15 at 07:30