Embeddable entity with @OneToMany attribute

前端 未结 1 1861
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 21:09

Say, I have following entities:

@Entity
public class A {
  @Id
  @GeneratedValue
  private Long id;

  @Embedded
  private B b;

  //getters and setters
}
         


        
相关标签:
1条回答
  • 2020-12-18 21:43

    In general that is possible with @JoinColumn annotation. It works also with embeddables.

    @OneToMany
    @JoinColumn(name="A_ID")
    private List<C> cList;
    

    If you are not happy with A_ID name for column given in embeddable, you can override column name in entity A:

    @AssociationOverride(name= "cList",
            joinColumns = @JoinColumn(name="SOME_NAME_FOR_JOIN_COLUMN_IN_TABLE_C"))
    @Embedded
    private B b;
    
    0 讨论(0)
提交回复
热议问题