我正在尝试在Rent表和RentAgreement表之间建立oneToMany关系,rent表具有复合键rentKey
@Setter
@Getter
@Entity
@Table(name = "Rent")
public class Rent {
@EmbeddedId
@Column(name = "rentKey")
private RentKey rentKey;
@OneToMany(mappedBy="rent", cascade = {CascadeType.REFRESH, CascadeType.REMOVE})
@JsonIgnoreProperties(value = "rent", allowSetters=true)
private Set<RentalAgreement> rentalAgreements;
...
RentKey是
@Data
@Setter
@Getter
@Embeddable
public class RentKey implements Serializable{
private String rentStartDate;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "agent_id", referencedColumnName = "id")
@JsonIgnoreProperties(value = "rents", allowSetters=true)
private Agent agent;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "client_id", referencedColumnName = "id")
@JsonIgnoreProperties(value = "rents", allowSetters=true)
private Client client;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "propertyRent_id", referencedColumnName = "id")
@JsonIgnoreProperties(value = "rents", allowSetters=true)
private PropertyRent propertyRent;
...
而RentAgreement是
@Data
@Entity
@Table(name = "RentalAgreement")
public class RentalAgreement {
@Id
@GeneratedValue
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="agent_id", referencedColumnName="agent_id"),
@JoinColumn(name="client_id", referencedColumnName="client_id"),
@JoinColumn(name="propertyRent_id", referencedColumnName="propertyRent_id")
})
@JsonIgnoreProperties(value = "rentalAgreements", allowSetters=true)
private Rent rent;
...
当我运行代码时,我得到
org.hibernate.AnnotationException:引用com.mikason.PropView.dataaccess.commercialEntity.Rent的com.mikason.PropView.dataaccess.documentEntity.RentalAgreement.rent的referencedColumnNames(agent_id,client_id,propertyRent_id)未映射到单个属性
谁能告诉我我做错了什么?谢谢
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。