最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Why does my ManyToMany relationship insert inconsistent records in the join table? - Stack Overflow

programmeradmin4浏览0评论

I have a Many-to-Many relationship between Faculty and Student entities in a Spring Boot JPA application.

  • Faculty has a List students mapped using @ManyToMany, and it is the owning side of the relationship.
  • Student has a List faculties, mapped with mappedBy="students".

I have helper methods (addStudent() in Faculty and addFaculty() in Student) that ensure bidirectional mapping.

However, when I persist faculty and students using saveAll(), I notice unexpected and inconsistent records in the join table (student_faculty).

Example of incorrect records in the join table:

sid sname
1003 Charles
1004 Dennis
1005 Elon
发布评论

评论列表(0)

  1. 暂无评论