JPA 上的连接获取中返回的子项数量错误
有一个 JPA OneToMany 关联
@OneToMany(mappedBy = "playlist", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@IndexColumn(name = "intSequence")
private List<Track> tracks;
我在相册类中
。当我使用 join fetch 加载专辑的曲目时,我将 3 个相同的曲目放入内存,而数据库中实际上有 3 个不同的专辑曲目,这恰好是 mysql 数据库中的最后一个曲目。
如果我将“列表”更改为“设置”,它将起作用 - 我得到所有 3 个曲目并且一切正常。我查了很多谷歌搜索和 JPA 文档,到目前为止还没有任何线索。有人可以给我一些线索吗?
I have a JPA OneToMany association
@OneToMany(mappedBy = "playlist", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@IndexColumn(name = "intSequence")
private List<Track> tracks;
in class Album.
When I am using join fetch to load the tracks of the album, I get 3 identical tracks into memory while there are actually 3 different tracks for the album in the database, which happens to be the last track in the mysql database.
It will work if I change the List to Set -- I get all 3 tracks and things work. I did lots of googling and JPA documentations, no clue so far. Can someone give me some clue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论