简体   繁体   English

重复数据休眠休眠

[英]Hibernate lazy loading with repeated data

I have two tables employee and bankname . 我有两个表employeebankname In employee table there is a column bank_name_id which refers the column of bank table. 在雇员表中,有一列bank_name_id ,它引用银行表的列。

I have mapped employee bank_name_id with bank bank_name_id with many to one 我已将员工bank_name_id与bank bank_name_id映射为多对一

I'm using spring mvc @RestController while returning it correctly fetch the data from bankname but converting into json its have repeated fetched data 我正在使用spring mvc @RestController同时将其正确返回,以从@RestController获取数据,但将其重复获取的数据转换为json

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: JSON输出:

{
    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 此银行名称数据重复

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. 根据您的结果,它表明您在emp实体中有两个变量,一个银行和另一个银行名称,因此请从emp实体中删除bankname变量。 and then check otherwise share you code here. 然后检查,否则在这里共享您的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM