欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JPA 常见@OneToMany,@ManyToOne,@OneToOne映射

程序员文章站 2022-04-12 18:01:26
...

 

JPA 常见@OneToMany,@ManyToOne,@OneToOne映射

 

	@ManyToOne(fetch = FetchType.EAGER, optional = true)
    //@JoinColumn(name="to_loc_no",referencedColumnName="life_cycle", insertable = false, updatable = false)
    @JoinColumns ({
            @JoinColumn(name="to_dept_no",referencedColumnName = "life_cycle",insertable = false, updatable = false),
            @JoinColumn(name="to_loc_no",referencedColumnName = "oid",insertable = false, updatable = false)
    })
	//to_dept_no, to_loc_no is in epoDetail table
	//life_cycle, oid is in epoHeader table
    private EpoHeader epoHeader;
	
	
	
	
	
	@OneToMany(fetch = FetchType.EAGER)
    //@JoinColumn(name="to_loc_no",referencedColumnName="life_cycle", insertable = false, updatable = false)
    @JoinColumns ({
            @JoinColumn(name="to_dept_no",referencedColumnName = "life_cycle",insertable = false, updatable = false),
            @JoinColumn(name="to_loc_no",referencedColumnName = "oid",insertable = false, updatable = false)
    })
	//to_dept_no, to_loc_no is in epoDetail table
	//life_cycle, oid is in epoHeader table
    private List<EpoDetail> epoDetails;
	
	@OneToOne(fetch = FetchType.EAGER, optional = true)
    @JoinColumns ({
            @JoinColumn(name="form_no",referencedColumnName = "form_no",insertable = false, updatable = false),
            @JoinColumn(name="form_type",referencedColumnName = "form_type",insertable = false, updatable = false)
    })
	//name="form_no", name="form_type" is in epoHeader
	//referencedColumnName = "form_no", referencedColumnName = "form_type" is in EpoForklift
    private EpoForklift epoForklift;
	
	@OneToMany(fetch = FetchType.EAGER)
	// forklift_oid is in EpoForklift
	// oid is in EpoForkliftSetup
    @JoinColumn(name = "oid", referencedColumnName = "forklift_oid", insertable = false, updatable = false)
    private List<EpoForkliftSetup> epoForkliftConfigs;