File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Simple One to Many not working in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Simple One to Many not working in Hibernate" Watch "Simple One to Many not working in Hibernate" New topic
Author

Simple One to Many not working in Hibernate

Darren Carter
Ranch Hand

Joined: Jul 08, 2010
Posts: 30
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





 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple One to Many not working in Hibernate