更改@Embedded的@ElementCollection的主键名称

时间:2018-11-05 10:36:46

标签: java spring hibernate

我正在使用Spring Boot 2.x,Spring Data REST,Hibernate(5.2 / 5.3)。

我有两个实体:

@Entity   
public class PaymentTerm extends AbstractEntity {

    @NotBlank
    @Column(nullable = false)
    private String name;

    @NotBlank
    @Column(nullable = false, unique = true)
    private String code;

    @NotNull
    @Column(nullable = false, columnDefinition = "BIT DEFAULT 0")
    private boolean endOfMonth = false;

    @NotNull
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private PaymentType paymentType;

    @ElementCollection
    private Set<PaymentDue> paymentsDue = new HashSet<>();

@Embeddable
public class PaymentDue {

    @Min(0)
    @NotNull
    @Column(nullable = false)
    private int days = 0;

    @Min(1)
    @Max(100)
    @NotNull
    @Column(nullable = false)
    private BigDecimal percentage = new BigDecimal(100);

Hibernate为嵌入式集合生成此主键:

enter image description here

我想更改主键的名称。有可能吗?

我知道有注解@AttributeOverride,但不能解决我的问题。

0 个答案:

没有答案