• 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

Hibernate many-to-one association does not work properly

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am new to Hibernate. I have a class Category which has many SubCategory. so I have created a bi-directional association like this:
-----------------Category.hbm.xml--------------------------


-----------------SubCategory.hbm.xml--------------------------


I have put a Set of sub categories under the Category class.

the project runs properly, but the problem is: when I want to show all Categories- it produces a table with the sub categories also!

i mean to say- the items under SubCategoryTable are also fetched..

could anyone please help me finding & solving the problem???
 
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
set lazy=true in second mapping like:


This will not load the subcategories untill you will not call the subCategories method of category class.
reply
    Bookmark Topic Watch Topic
  • New Topic