• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hbm.xml question

 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 tables: Company, Company_Item and Item. Company_Item holds the relationship between Company and Item. Pretty straight forward.

In my Company.hbm.xml and Item.hbm.xml files I have the following set defined. Notice I do not lazy load the CompanyItems. I load them real time:




In my CompanyItem.hbm.xml file I have the following many-to-ones defined. Notice I do not lazy load the Company and Items. I load them real time:



So my question is this:
If I load a Company and that automatically loads a companyItems set, then when the companyItems loads that triggers a Company to load, does the loading ever end? It seems like it could be an infinite loop. Its like looking in a mirror that faces another mirror - you see back and forth forever.

Company
--CompanyItem
--Company
--CompanyItem
--Company

Is this a problem or is Hibernate smart enough to know to not load everything n times? Thanks
 
Pierre Henry
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer is ... YES

You have to be carefull It's not a recursive association.

I suggest you try a <many-to-many> tag for your association.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic