Java 避免Hiberate中的循环引用

Java 避免Hiberate中的循环引用,java,sql,hibernate,spring-mvc,hibernate-mapping,Java,Sql,Hibernate,Spring Mvc,Hibernate Mapping,我有三个域类。。目录,DeviceInventory,DeviceInventory信息。。 Catalog类包含所有正在使用的设备,DeviceInventory类提供有关设备启动成本的简要信息,DeviceInventoryInfo提供有关设备库存的详细说明 设备资源清册引用目录类中名为modelId的字段。Catalog类与DeviceInventory具有一对多关系。然而,DeviceInventoryInfo类引用设备清单id具有一对一关系的deviceInventory类。因此,每当

我有三个域类。。目录,DeviceInventory,DeviceInventory信息。。 Catalog类包含所有正在使用的设备,DeviceInventory类提供有关设备启动成本的简要信息,DeviceInventoryInfo提供有关设备库存的详细说明

设备资源清册引用目录类中名为modelId的字段。Catalog类与DeviceInventory具有一对多关系。然而,DeviceInventoryInfo类引用设备清单id具有一对一关系的deviceInventory类。因此,每当我调用insertweb服务时,它都会显示语法异常。这就是我在控制台里看到的

Hibernate: select inventoryr0_.device_inventory_id as device_i1_7_, inventoryr0_.device_model_id as device_m4_7_, inventoryr0_.hospital_id as hospital2_7_, inventoryr0_.manufacturer_id as manufact3_7_, inventoryr0_.physical_status as physical5_7_, inventoryr0_.device_status as device_s6_7_ from device_inventory_register inventoryr0_ where inventoryr0_.device_inventory_id=?
Hibernate: select catalog0_.device_model_id as device_m1_4_0_, catalog0_.baseline_cost as baseline2_4_0_, catalog0_.device_category_id as device_c3_4_0_, catalog0_.device_classification_id as device_c4_4_0_, catalog0_.device_description as device_d5_4_0_, catalog0_.device_code as device_c6_4_0_, catalog0_.device_name as device_n7_4_0_, catalog0_.device_type_id as device_18_4_0_, catalog0_.equivalent_model_name as equivale8_4_0_, catalog0_.hospital_id as hospital9_4_0_, catalog0_.life_expectancy as life_ex10_4_0_, catalog0_.manufacturer_id as manufac11_4_0_, catalog0_.meter_type as meter_t12_4_0_, catalog0_.device_model_num as device_13_4_0_, catalog0_.replacement_cost as replace14_4_0_, catalog0_.device_status as device_15_4_0_, catalog0_.device_subcategory_id as device_16_4_0_, catalog0_.support_status as support17_4_0_, catalog0_.useful_life as useful_19_4_0_, categoryma1_.device_category_id as device_c1_5_1_, categoryma1_.device_category_description as device_c2_5_1_, categoryma1_.device_category as device_c3_5_1_, categoryma1_.hospital_id as hospital4_5_1_, categoryma1_.status as status5_5_1_, devicetype2_.device_type_id as device_t1_11_2_, devicetype2_.device_type_description as device_t2_11_2_, devicetype2_.device_type as device_t3_11_2_, devicetype2_.hospital_id as hospital4_11_2_, subcategor3_.device_subcategory_id as device_s1_10_3_, subcategor3_.device_category_id as device_c2_10_3_, subcategor3_.hospital_id as hospital3_10_3_, subcategor3_.status as status4_10_3_, subcategor3_.device_subcategory_description as device_s5_10_3_, subcategor3_.device_subcategory as device_s6_10_3_ from device_catalog catalog0_ inner join device_category_master categoryma1_ on catalog0_.device_classification_id=categoryma1_.device_category_id inner join device_type_master devicetype2_ on catalog0_.device_type_id=devicetype2_.device_type_id inner join device_subcategory_master subcategor3_ on catalog0_.device_subcategory_id=subcategor3_.device_subcategory_id where catalog0_.device_model_id=?
 Hibernate: select inventoryr0_.s.no as s1_8_2_, inventoryr0_.date_of_acceptance as date_of_2_8_2_, inventoryr0_.account as account3_8_2_, inventoryr0_.baseline_cost as baseline4_8_2_, inventoryr0_.cost_to_date as cost_to_5_8_2_, inventoryr0_.device_inventory_id as device_i6_8_2_, inventoryr0_.stored_on_device as stored_o7_8_2_, inventoryr0_.hippa_data_id as hippa_da8_8_2_, inventoryr0_.date_of_installation as date_of_9_8_2_, inventoryr0_.date_of_launch as date_of10_8_2_, inventoryr0_.life_expectancy as life_ex11_8_2_, inventoryr0_.network_aware as network12_8_2_, inventoryr0_.network_connected as network13_8_2_, inventoryr0_.original_cost as origina14_8_2_, inventoryr0_.priority_id as priorit15_8_2_, inventoryr0_.date_of_purchase as date_of16_8_2_, inventoryr0_.date_of_receipt as date_of17_8_2_, inventoryr0_.replacement_cost as replace18_8_2_, inventoryr0_.risk_id as risk_id19_8_2_, inventoryr0_.skill_id as skill_i20_8_2_, inventoryr0_.transmitted_by_device as transmi21_8_2_, inventoryr0_.useful_life as useful_22_8_2_, inventoryr1_.device_inventory_id as device_i1_7_0_, inventoryr1_.device_model_id as device_m4_7_0_, inventoryr1_.hospital_id as hospital2_7_0_, inventoryr1_.manufacturer_id as manufact3_7_0_, inventoryr1_.physical_status as physical5_7_0_, inventoryr1_.device_status as device_s6_7_0_, catalog2_.device_model_id as device_m1_4_1_, catalog2_.baseline_cost as baseline2_4_1_, catalog2_.device_category_id as device_c3_4_1_, catalog2_.device_classification_id as device_c4_4_1_, catalog2_.device_description as device_d5_4_1_, catalog2_.device_code as device_c6_4_1_, catalog2_.device_name as device_n7_4_1_, catalog2_.device_type_id as device_18_4_1_, catalog2_.equivalent_model_name as equivale8_4_1_, catalog2_.hospital_id as hospital9_4_1_, catalog2_.life_expectancy as life_ex10_4_1_, catalog2_.manufacturer_id as manufac11_4_1_, catalog2_.meter_type as meter_t12_4_1_, catalog2_.device_model_num as device_13_4_1_, catalog2_.replacement_cost as replace14_4_1_, catalog2_.device_status as device_15_4_1_, catalog2_.device_subcategory_id as device_16_4_1_, catalog2_.support_status as support17_4_1_, catalog2_.useful_life as useful_19_4_1_ from device_inventory_register_info inventoryr0_ inner join device_inventory_register inventoryr1_ on inventoryr0_.device_inventory_id=inventoryr1_.device_inventory_id left outer join device_catalog catalog2_ on inventoryr1_.device_model_id=catalog2_.device_model_id where inventoryr0_.device_inventory_id=?

@Entity
@Table(name="device_catalog")
public class Catalog {




    private Integer modelId;
    private Integer hospitalId;
    private Integer manufacturerId;
    private String deviceCode;
    private String modelNumber;
    private String deviceName;
    private String description;
    private String equiModelName;
    private Integer classificationId;
    private Integer typeId;
    private Integer categoryId;
    private Integer subCategoryId;
    private String meterType;
    private Integer baselineCost;
    private Integer replacementCost;
    private Integer usefulLife;
    private Integer lifeExpectancy;
    private String supportStatus;
    public enum Status{Active, Inactive}

    @JsonBackReference
    private ManufacturerMaster master;

    private ClassificationMaster classificationMaster;

    private DeviceTypeMaster deviceTypeMaster;

    private CategoryMaster categoryMaster;

    private SubCategoryMaster subCategoryMaster;

    private Status status;

    @JsonManagedReference
    private Set<InventoryRegister> inventoryRegisters;

@Entity
@Table(name="device_inventory_register_info")
public class InventoryRegisterInfo {


    private Integer serialNum;
    private Integer deviceInventoryId;
    private String account;
    private Integer originalCost;
    private Integer replacementCost;
    private Integer costToDate;
    private Integer baselineCost;
    private Date purchaseDate;
    private Date receiptDate;
    private Date acceptanceDate;
    private Date installationDate;
    private Integer usefulLife;
    private Integer lifeExpectancy;
    private Date launchDate;
    private String networkAware;
    private String networkConnected;
    private String deviceStored;
    private String transmittedByDevice;
    private Integer skillId;
    private Integer priorityId;
    private Integer hippaId;
    private Integer riskId;

    private InventoryRegister inventoryRegister;

@Entity
@JsonAutoDetect
@Table(name="device_inventory_register")
public class InventoryRegister {

    private Integer deviceInventoryId;
    private Integer modelId;
    private Integer manufacturerId;
    private Integer hospitalId;
    private String physicalStatus;
    private Status status;

    @JsonBackReference
    private Catalog catalog;

    private InventoryRegisterInfo inventoryRegisterInfo;
Hibernate:选择Inventory0\u设备库存id作为设备库存i1\u 7\u,选择Inventory0\u设备型号id作为设备库存m4\u 7\u,选择Inventory0\u医院id作为医院2\u 7\u,选择Inventory0\u制造商id作为制造商3\u 7\u,选择Inventory0\u物理状态作为物理状态5\u 7\u,清单0.设备清单状态为设备清单6.设备清单7.来自设备清单寄存器清单0,其中清单0.设备清单id=?
休眠:选择目录0。设备型号id作为设备m1\U 4\U 0,目录0。基线成本作为基线2\U 4\U 0,目录0。设备类别id作为设备c3\U 4\U 0,目录0。设备分类id作为设备c4\U 4\U 0,目录0。设备描述作为设备d5\U 4\U 0,目录0。设备代码作为设备c6\U 4\U 4\U 0,设备名为设备,catalog0.设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id,目录0.更换成本为更换14.更换目录0.设备状态为设备15.更换目录0.设备子类别id为设备16.更换成本为更换成本14.更换成本为更换成本,目录0.设备状态为设备15.更换成本为更换成本,目录0.设备子类别id为设备16.更换成本为更换成本,目录0.支持状态为支持17.设备使用寿命为有用寿命19.设备类别1.设备类别id为设备c1.设备类别1.设备描述,类别1.设备类别为设备c3.设备类别1.医院id为医院4.设备类别1.状态5.设备类型2.设备类型id为设备t1.设备类型2.设备类型描述为设备t2.设备类型2.设备类型描述为设备t2.设备描述为设备t2.设备类型3.设备类型2.设备类型,子类别3、设备子类别id为设备s1、10、3、子类别3、设备类别id为设备c2、10、3、医院id为医院3、子类别3、状态4、10、3、子类别描述为设备s5、10、3、,子类别3.设备子类别作为设备6.设备10.设备3.来自设备目录0.内部联接设备.目录0.内部联接设备.类别1.设备.分类id=类别1.设备.类别id内部联接设备.类别0.设备类型id内部联接设备.主设备类型2.设备类型id=设备类型2.设备.类型id内部联接设备.子类别3.设备在catalog0\u0.device\u subcategory\u id=子类别3\u0.device\u subcategory\u id上,其中catalog0\u0.device\u model\u id=?
休眠:选择Inventory0.s.no作为s1_8_2_,Inventory0.date_作为2_8_2_的日期,Inventory0.account作为account3_8_2_,Inventory0.baseline作为基线4_8_2_,Inventory0.cost_作为5_8_2_的成本,Inventory0,库存。日期。安装日期作为安装日期作为安装日期作为安装日期作为安装日期作为安装日期作为安装日期作为安装日期作为安装日期的日期,库存。库存。日期。日期作为安装日期作为安装日期作为安装日期作为安装日期的日期,库存。库存。日期作为发布日期作为发射日期作为发布日期作为发布日期作为发布日期的发布日期作为发布日期的发布日期作为发布日期,库存,库存,库存,库存。寿命。预期寿命作为使用寿命,库存,库存,库存。网络。网络意识到网络意识到网络,网络意识到网络,网络意识到网络意识到网络意识到网络,网络,库存,库存,库存,网络网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,网络,存货0.优先权id为优先权15.存货0.购买日期16.存货0.接收日期17.存货0.替换成本18.存货0.风险id为风险id 19.存货0.技能id为技能id 20.由设备传输的存货2,存货0.使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为使用寿命为,目录2.设备型号id为设备m1.设备4.设备1.目录2.基线成本为基线2.设备4.设备类别id为设备c3.设备型号id为设备m1.设备id为设备c4.设备1.目录2.设备描述为设备d5.设备4.设备名称,catalog2.设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为设备类型id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id为制造商id,目录2。更换成本为更换14。目录2。设备状态为设备15。目录2。设备子类别id为设备16。目录2。支持状态为支持17。4。1,catalog2.Usage\u life as Usage\u 19\u 4\u 1\u来自设备\u inventory\u register\u info Inventory0\u内部连接设备\u inventory\u register Inventory1\u on Inventory0.device\u inventory\u id=Inventory1.device\u inventory\u id离开外部连接设备\u inventory目录2\u on inventory\u1.device\u model\u id=catalog2\u型号\u id,其中Inventory0\u0.device\uU inventory\u id=?
@实体
@表(name=“设备目录”)
公共类目录{
私有整数modelId;
私人整数医院ID;
私有整数制造商RID;
专用字符串设备代码;
私有字符串模型号;
私有字符串deviceName;
私有字符串描述;
私有字符串equiModelName;
私有整数分类ID;
私有整数类型ID;
私有整数