• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple One to Many not working in Hibernate  RSS feed

Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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

Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!