Traversing ORM relationships returns duplicate results

I have 4 tables -- `store, catalog_galleries, catalog_images, and catalog_financials`. When I traverse the relationship from `store --> catalog_galleries --> catalog_images` in other words: `store.getCatalogGallery().getCatalogImages()` I get duplicate records. Does anyone know what could be the cause of this? Any suggestions on where to look? The `store` table has a `OneToOne` relationship with `catalog_galleries` which in turn has a `OneToMany` relationship with `catalog_images` and an eager fetch type. The `store` table also has a `OneToMany` relationship with `catalog_financials`. Below are the relevant entities: Store entity @Entity @Table(name="store") public class Store { ... private CatalogGallery gallery; ... @OneToOne(mappedBy="store") public CatalogGallery getGallery() { return gallery; } } CatalogGallery entity @Entity @Table(name="catalog_galleries") public class CatalogGallery { ... private Store store; private Collection catalogImages; ... @OneToOne @PrimaryKeyJoinColumn public Store getStore() { return store; } @OneToMany(mappedBy="catalogGallery", fetch=FetchType.EAGER) public Collection getCatalogImages { return catalogImages; } } CatalogImage entity @Entity @Table(name="catalog_images") public class CatalogImage { ... private CatalogGallery catalogGallery; ... @ManyToOne @JoinColumn(name="gallery_id", insertable=false, updatable=false) public CatalogGallery getCatalogGallery() { return catalogGallery; } }
Not enough information, please provide your JPA classes with mappings. Have you tried to look at generated SQL?

以上就是Traversing ORM relationships returns duplicate results的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准