java | jpa |如何将多个重复的注解组合成单个注解?

rn0zuynd  于 2021-07-11  发布在  Java
关注(0)|答案(0)|浏览(161)

在下面的jpa代码中,我有大约20个字段,需要在element collection中为这些字段创建20个表。

@ElementCollection(targetClass = JtcaTab.class)
    @CollectionTable(name = "JTCA_MATERIAL", joinColumns = @JoinColumn(name = "trackingId"))
    @AttributeOverrides({
        @AttributeOverride(name = "company",column = @Column(name = "company")),
        @AttributeOverride(name = "orderDate",column = @Column(name = "orderDate")),
        @AttributeOverride(name = "estimateDate",column = @Column(name = "estimateDate")),
        @AttributeOverride(name = "cost",column = @Column(name = "cost")),
        @AttributeOverride(name = "hours",column = @Column(name = "hours")),
        @AttributeOverride(name = "quantityRun",column = @Column(name = "quantityRun")),
        @AttributeOverride(name = "quantityScrapped",column = @Column(name = "quantityScrapped")),
        @AttributeOverride(name = "quantityReject",column = @Column(name = "quantityReject")),
        @AttributeOverride(name = "blankQty",column = @Column(name = "blankQty")),
        @AttributeOverride(name = "certificateNumber",column = @Column(name = "certificateNumber")),
        @AttributeOverride(name = "certificatePath",column = @Column(name = "certificatePath")),
        @AttributeOverride(name = "comments",column = @Column(name = "comments")),
        @AttributeOverride(name = "user",column = @Column(name = "user")),
        @AttributeOverride(name = "completed",column = @Column(name = "completed")),
    })
    private List<JtcaTab> jtcaMaterial;

    @ElementCollection(targetClass = JtcaTab.class)
    @CollectionTable(name = "JTCA_CUTOFF", joinColumns = @JoinColumn(name = "trackingId"))
    @AttributeOverrides({
        @AttributeOverride(name = "company",column = @Column(name = "company")),
        @AttributeOverride(name = "orderDate",column = @Column(name = "orderDate")),
        @AttributeOverride(name = "estimateDate",column = @Column(name = "estimateDate")),
        @AttributeOverride(name = "cost",column = @Column(name = "cost")),
        @AttributeOverride(name = "hours",column = @Column(name = "hours")),
        @AttributeOverride(name = "quantityRun",column = @Column(name = "quantityRun")),
        @AttributeOverride(name = "quantityScrapped",column = @Column(name = "quantityScrapped")),
        @AttributeOverride(name = "quantityReject",column = @Column(name = "quantityReject")),
        @AttributeOverride(name = "blankQty",column = @Column(name = "blankQty")),
        @AttributeOverride(name = "certificateNumber",column = @Column(name = "certificateNumber")),
        @AttributeOverride(name = "certificatePath",column = @Column(name = "certificatePath")),
        @AttributeOverride(name = "comments",column = @Column(name = "comments")),
        @AttributeOverride(name = "user",column = @Column(name = "user")),
        @AttributeOverride(name = "completed",column = @Column(name = "completed")),
    })
    private List<JtcaTab> jtcaCutoff;

    .

如果您看到上面的注解集是公共的,只有集合表名称不同。重复20次。
有没有办法创建一个包含上述所有注解的公共集,即实体中的最小集?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题