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

1
  • Can you share xml or annotation mapping. Commented Nov 4, 2015 at 13:50

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.