• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple One to Many not working in Hibernate

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I really hope someone could help as I been struggling with an issue with hibernate and a spring mvc app. I must be doing something silly and was hoping someone could help.

I have the following relationships


1) SiteMenu has many MenuSection
2) SiteMenu has one Site
2) MenuSection has Many Products


I simply trying to retrieve a SiteMenu object which contains all the MenuSecions and associated Products. However when I add the products to my hibernate mapping (MenuSection.hbm), I receive duplicate MenuSection objects in my query. Removing the products association returns the correct number of MenuSections.

Here are the Hibernate Mappings



Here is my Criteria query



Why is it if I introduce products it duplicates the records returned? Can some please help as I am not sure what to do?

Best Regards





reply
    Bookmark Topic Watch Topic
  • New Topic