0

これは私のJavaコードです:3つのエンティティを含むCompanyTypeRelation ,CompanyType,Department

public class CompanyTypeRelation  implements java.io.Serializable {

   private static final long serialVersionUID = 4227115995926533087L;
   // Fields    

    private long id;
    private CompanyType companyType;
    private Department department;
    private long operator;
    private String operateTime;
    // the relationship
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="company_type_id", nullable=false)

    public CompanyType getCompanyType() {
       return this.companyType;
    }

    public void setCompanyType(CompanyType companyType) {
      this.companyType = companyType;
    }
        // the relationship
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="company_id", nullable=false)

    public Department getDepartment() {
       return this.department;
    }

    public void setDepartment(Department department) {
    this.department = department;
    }
    ..............
    other code:
}

これは私のクエリSQLです:

SELECT c 
FROM com.hna.dt.orm.CompanyTypeRelation c 
LEFT JOIN c.companyType ct LEFT JOIN c.department cd

departmentName上記のDepartmentSQLで取得できますか?

4

1 に答える 1

0

departmentName が部門テーブルにあると仮定すると、cd.name (または列名が何であれ) を選択リストに追加するだけです。

于 2013-08-06T07:32:57.373 に答える