Hibernate many-to-many data retrieval, via query

前端 未结 2 813
误落风尘
误落风尘 2021-01-24 00:49

Please help me, I think there is something that I am not doing correct. I have User and Contact, that are in Many-to-Many relation.

<
2条回答
  •  无人及你
    2021-01-24 01:39

    In the XML mapping Contact, the mapping of userSet is completely wrong:

    
     
      
      
        
        
      
     
    
    

    It should be:

      
        
        
      
    

    It looks to me like you copy-and-pasted this from User and then didn't update it.

    Why are you using XML rather than annotations? XML is much more error-prone, as you can see. In addition, a lot of these settings should be defaulted correctly by Hibernate. If you had just left out some of these attributes, it probably would have worked fine.

提交回复
热议问题