【发布时间】:2013-04-05 17:51:45
【问题描述】:
如下所述:
- Cascade on delete using unidirectional Many-To-Many mapping
- How to remove entity with ManyToMany relationship in JPA (and corresponding join table rows)?
- JPA JPQL: select items when attribute of item (list/set) contains another item
从@ManyToMany 映射中删除条目时,需要手动调整以删除外键。
多年来我一直在使用自己的 JPA CRUD,并为此提供了一个很好的解决方案:CrudDao 例如NoteDao.
但我最近对Spring JPA 以及通过声明接口然后在@Entity 上创建类似名称的namedQuerys 来自动生成 Cruds 的能力印象深刻。
但是如何解决@ManyToMany 删除问题?我基本上会在我的 Crud 上使用 remove 方法来公开 JPA 的这个“特性”。
【问题讨论】: