Spring 许多双向级联,保存工作在一方(拥有方),而不是另一方

Spring 许多双向级联,保存工作在一方(拥有方),而不是另一方,spring,hibernate,spring-boot,Spring,Hibernate,Spring Boot,当我使用QuestionRepository持久化问题(将标记添加到数组中)时,相应的标记会自动保存,以及Question\u Tag表中的行,但是当我使用标记存储库保存标记(将问题添加到其问题数组中)时,不会发生任何事情,我也会将级联添加到另一侧,问题已创建,但在question\u标签表中没有任何内容 //Tag Entity @ManyToMany(mappedBy = "tags") private List<Question> questions; //QuestionE

当我使用QuestionRepository持久化问题(将标记添加到数组中)时,相应的标记会自动保存,以及
Question\u Tag
表中的行,但是当我使用标记存储库保存标记(将问题添加到其问题数组中)时,不会发生任何事情,我也会将级联添加到另一侧,问题已创建,但在
question\u标签
表中没有任何内容

//Tag Entity
@ManyToMany(mappedBy = "tags")
private List<Question> questions;

//QuestionEntity
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(name = "question_tag",
        joinColumns = @JoinColumn(name = "question_id"),
        inverseJoinColumns = @JoinColumn(name = "tag_id")
)
private List<Tag> tags;

//Saving the Tag entity
Tag tag = tagRepository.findById(1L).get();
Question q = new Question();
q.setTitle("tryme44");
q.setTxt("ttttttrrrrryyyyb");
tag.addQuestion(q);
tagRepository.save(tag);
//标记实体
@多个(mappedBy=“标记”)
私人名单问题;
//问题实体
@ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE})
@JoinTable(name=“question\u tag”,
joinColumns=@JoinColumn(name=“question\u id”),
inverseJoinColumns=@JoinColumn(name=“tag\u id”)
)
私有列表标签;
//保存标记实体
Tag Tag=tagRepository.findById(1L.get();
问题q=新问题();
q、 片名(“tryme44”);
q、 setTxt(“tttttt rrrrr yyyyb”);
附加问题(q);
tagRepository.save(标记);