JPA. JoinTable and two JoinColumns

后端 未结 1 1599
野趣味
野趣味 2021-02-09 18:50

I need to create table PORTATION_MODEL_SET. And I need to create two keys from table portation and one key from table phone_model

相关标签:
1条回答
  • 2021-02-09 19:13
    @ManyToMany(targetEntity = JDBCPhoneModel.class,
                cascade = CascadeType.ALL,
                fetch = FetchType.LAZY)
    @JoinTable(name = "PORTATION_MODEL_SET",
               joinColumns = {@JoinColumn(table = "PORTATION",
                                          name = "fk_portation_id", 
                                          referencedColumnName = "id"),
                              @JoinColumn(table = "PORTATION",
                                          name = "fk_content_id",                               
                                          referencedColumnName = "fk_content_id", 
                                          nullable = true)},
               inverseJoinColumns = @JoinColumn(table = "PHONE_MODEL",
                                                name="fk_phone_model_id",
                                                referencedColumnName = "id"))
    private List<PhoneModel> phoneModel;
    

    You were missing the referencedColumnName from the inverseJoinColumns definition. Please see if it's works for you.

    0 讨论(0)
提交回复
热议问题