Hibernate配置实体类的属性

Hibernate配置实体类的属性既可以在页面显示关联实体类的所有属性,在插入该属性时又可以只插入单一属性

private String companyCode;
private CompanyEntity company;

    @Column(name = "company_code", length = 32)    
    public String getCompanyCode() {
      return companyCode;
    }

    public void setCompanyCode(String companyCode) {
      this.companyCode = companyCode;
    }//插入时使用
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="company_code",insertable = false, updatable = false,referencedColumnName="code")
    public CompanyEntity getCompany() {
      return company;
    } //显示时使用

    public void setCompany(CompanyEntity company) {
      this.company = company;
    }

 

posted @ 2017-11-28 11:49  heyesp  阅读(753)  评论(0编辑  收藏  举报