Hibernate org.hibernate.MappingException 中的复合键错误:无法确定类型:java.util.Set,

Error in composite key in Hibernate org.hibernate.MappingException: Could not determine type for: java.util.Set,

朋友们,我陷入了 Hibernate 复合键的问题。 错误:org.hibernate.MappingException:无法确定类型:java.util.Set,在 table:IDP_UserManagerMapping,对于列:[org.hibernate.mapping.Column(idps) ]。我已经尝试过@transient 和其他东西但没有效果请帮助。

public class IDPUserManagerMapping implements Serializable {
    private Long id;
    private Users user;
    private Users manager;
    private Users assessor;

    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumns({
        @JoinColumn(name="user_id" ,referencedColumnName = "user_id"),
        @JoinColumn(name="manager_id" ,referencedColumnName = "manager_id")
        ,@JoinColumn(name="assessor_id" ,referencedColumnName = "assessor_id")
    })
    @Cascade(CascadeType.ALL)
    private Set<IDPMaster> idps = null;

    @Id
    @SequenceGenerator(sequenceName="idp_usermanagermapping_id_seq",name="idp_usermanagermapping_id_seq_gen")
    @GeneratedValue(generator="idp_usermanagermapping_id_seq_gen")
    @Column(name="id",nullable=false,unique=true,updatable=false)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }

    public Set<IDPMaster> getIdps() {
        return idps;
    }
    public void setIdps(Set<IDPMaster> idps) {
        this.idps = idps;
    }
        @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="user_id",nullable=false)
    public Users getUser() {
        return user;
    }
    public void setUser(Users user) {
        this.user = user;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="manager_id",nullable=false)
    public Users getManager() {
        return manager;
    }
    public void setManager(Users manager) {
        this.manager = manager;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="assessor_id")
    public Users getAssessor() {
        return assessor;
    }
    public void setAssessor(Users assessor) {
        this.assessor = assessor;
    }
    }

第二个实体

public class IDPMaster implements Serializable {
    private Long id;
    private Users managerUser;
    private Users assessorUser;
    private Users idpUsers;
    @Id
    @SequenceGenerator(name="idp_master_id_seq_gen",sequenceName="idp_master_id_seq")
    @GeneratedValue(generator="idp_master_id_seq_gen")
    @Column(name="id",nullable=false,unique=true)
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="user_id",nullable=false)
    public Users getIdpUsers() {
        return idpUsers;
    }
    public void setIdpUsers(Users idpUsers) {
        this.idpUsers = idpUsers;
    }
    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="manager_id")
    public Users getManagerUser() {
        return managerUser;
    }
    public void setManagerUser(Users managerUser) {
        this.managerUser = managerUser;
    }

    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="assessor_id")
    public Users getAssessorUser() {
        return assessorUser;
    }
    public void setAssessorUser(Users assessorUser) {
        this.assessorUser = assessorUser;
    }
    }

你应该移动注释

@OneToMany(fetch = FetchType.LAZY)
    @JoinColumns({
        @JoinColumn(name="user_id" ,referencedColumnName = "user_id"),
        @JoinColumn(name="manager_id" ,referencedColumnName = "manager_id")
        ,@JoinColumn(name="assessor_id" ,referencedColumnName = "assessor_id")
    })
    @Cascade(CascadeType.ALL)

private Set<IDPMaster> idps = null;public Set<IDPMaster> getIdps() getter

Hibernate 按 ID 列分析注释,如果你在 getter 上使用注释,你应该在所有地方使用 getter 注释。