Nested embeddable - AttributeOverride for embeddable within embeddable

余生长醉 提交于 2019-11-30 17:43:08

Hi you have to use @AttributeOverrides judicially,you have to override attributes once again in entity that you have done in embeddable ReportCostValues class, hope code below is what you are looking for.

@Entity 
public class ReportCostEntity implements  Serializable {

    @Id
    private Long id;

    @Embedded   
    @AttributeOverrides( {
        @AttributeOverride(name="coveredByGrant.amount", column = @Column(name="contracted_coveredByGrant") ),
        @AttributeOverride(name="foundedFromOwnResources.amount", column = @Column(name="contracted_foundedFromOwnResources")),
        @AttributeOverride(name="personalContribution.amount", column = @Column(name="contracted_personalContribution"))
    } )
    private ReportCostValues contracted;

    @Embedded
    @AttributeOverrides( {
        @AttributeOverride(name="coveredByGrant.amount", column = @Column(name="current_coveredByGrant") ),
        @AttributeOverride(name="foundedFromOwnResources.amount", column = @Column(name="current_foundedFromOwnResources")),
        @AttributeOverride(name="personalContribution.amount", column = @Column(name="current_personalContribution"))
    } )
    private ReportCostValues current;

    @Embedded 
    @AttributeOverrides( {
        @AttributeOverride(name="coveredByGrant.amount", column = @Column(name="previousReport_coveredByGrant") ),
        @AttributeOverride(name="foundedFromOwnResources.amount", column = @Column(name="previousReport_foundedFromOwnResources")),
        @AttributeOverride(name="personalContribution.amount", column = @Column(name="previousReport_personalContribution"))
    } )
    private ReportCostValues previousReport;




} 

Hope this helps !!!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!