Why am I getting Mapping Exception?

前端 未结 3 1814
孤城傲影
孤城傲影 2021-01-29 04:49

I am getting :

org.hibernate.MappingException: Foreign key (FKBB979BF4266AA123:address [a_id]))
must have same number of columns as the referenced 
primary key (         


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-29 05:26

    For a ManyToMany Relationshhip you need a dedicated mapping table

    6.2.4. Collections of values and many-to-many associations

    i.e. You need something like a PersonAddress Table

    CREATE TABLE personaddress (p_id integer, a_id integer)
    

    Where p_id is a FK Reference to the Person Table and a_id a FK Reference to the Address Table

提交回复
热议问题