org.hibernate.MappingException: Unable to find column with logical name

前端 未结 3 583
盖世英雄少女心
盖世英雄少女心 2020-12-31 01:21

hi my tables are as follows:

1- medical_company:

  • medical_company_id foreign key on account_entity ta
相关标签:
3条回答
  • 2020-12-31 01:29

    This error is telling you that there is no column on the medical_company table called medical_company_id. The column on medical_company is just called id.

    0 讨论(0)
  • 2020-12-31 01:30

    For those who ran into this problem and are using globally_quoted_identifiers, this helped me:

    Change

    @JoinColumns({
        @JoinColumn(name = "new_col_1", referencedColumnName = "ref_col_1"),
        @JoinColumn(name = "new_col_2", referencedColumnName = "ref_col_2")
    })
    

    To

    @JoinColumns({
        @JoinColumn(name = "new_col_1", referencedColumnName = "`ref_col_1`"),
        @JoinColumn(name = "new_col_2", referencedColumnName = "`ref_col_2`")
    })
    

    Notice the backtick wrapping the referencedColumnName value.

    0 讨论(0)
  • 2020-12-31 01:37

    I would remove the referencedColumnName attribute in MedicalCompany because you are naming the primary key field of AccountEntity. I think it is only necessary if you if it references a non-primary-key field.

    @JoinColumn(name = "medical_company_id", referencedColumnName = "account_entity_id")
    
    0 讨论(0)
提交回复
热议问题