1

各クエリで完了する、リレーションをCompanyUser.companyRolCompanyUsers持つプロパティが必要です。OneToMany

JPA company_usrエンティティ:

@Entity
@Table(name = "company_usr")
public class CompanyUser extends BaseModel implements Serializable {

    @Id
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(nullable = false)
    private Company company;
    @Id
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "usr_id", nullable = false)
    private User user;

    @Column(nullable = false)
    private Boolean external;

    @OneToMany(fetch = FetchType.EAGER)
    private List<CompanyRolCompanyUser> companyRolCompanyUsers;

....

JPA companyRol_companyUsrエンティティ:

@Entity
@Table(name = "companyRol_companyUsr")
public class CompanyRolCompanyUser extends BaseModel implements Serializable {

    @Id
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumns({
        @JoinColumn(name="companyuser_company_id",    referencedColumnName="company_id"),
        @JoinColumn(name="companyuser_usr_id", referencedColumnName="usr_id")
        })
    private CompanyUser companyUser;

    @Id
    @ManyToOne(fetch = FetchType.EAGER)
    private CompanyRol companyRol;

....

プロパティを正しく設定mappedByするにはどうすればよいですか?companyRolCompanyUsers

4

2 に答える 2

0

あなたが達成したいものを手に入れたら、次のようなものが必要だと思います:

@OneToMany(fetch = FetchType.EAGER, mappedBy="companyUser")
private List<CompanyRolCompanyUser> companyRolCompanyUsers;
于 2013-03-22T11:41:54.320 に答える