Why am I getting Mapping Exception?

前端 未结 3 1940
孤城傲影
孤城傲影 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:32

    You need to specify different table name for many-to-many association as it's handled by a separate table:

    
          
              
          
          
          
              
              
          
    
    

    Note that now references to person_addresses table. With default configuration, Hibernate is able to create it automatically.

    There's another mistake that I see: ID generator for Address entity should not be foreign, it's usually used in 1-to-1 relationships (uses ID of another associated object). You can use the same 'increment' use used for Person entity:

    
        
            
        
        
    
    

提交回复
热议问题