0

代码如下

@Embeddable
@Data
public class TransferNo{

    @Column(name = "transfer_no")
    private String value;
}
@Entity
@Data
public class AssetTransfer{

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Embedded
    private TransferNo transferNo;
}
@Entity
@Data
public class AssetBuyBack{
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    
    @OneToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinColumn(name = "transfer_no", referencedColumnName = "transfer_no", insertable = false, updatable = false)
    private AssetTransfer assetTransfer;
}

报错如下
org.hibernate.MappingException: Repeated column in mapping for entity: AssetTransfer column: transfer_no (should be mapped with insert="false" update="false")

如果 TransferNo 是 String 就不会有这个问题

ccc1994 16
6月3日提问
0 个回答

撰写答案

推广链接