I guess writting things out help, I saw the problem right after sending it. I am fetching the parent and the child in the same map.
Kris Rasmussen <[EMAIL PROTECTED]> wrote:
Kris Rasmussen <[EMAIL PROTECTED]> wrote:
I have table with a parent child relationship. I have been trying to figure out why so many database calls are being made because it appears that there are more than there should each time a web page loads. I tryed turning off lazy-loading because I thought it might not be working, but when i did I quickly overflowed the stack and the number of sql queries went from about 19 to 600.If my table only has 6 rows in it and there are definatly no loops in the paret child relationships then I don't know how this many queries could be possible.Any ideas what is going on?Here is my code...
<resultMap id="getPageResult" class="page">
<result property="siteId" column="page.SiteId"/>
<result property="pageId" column="page.PageId"/>
<result property="parentPageId" column="page.ParentPageId"/>
<result property="title" column="page.Title"/>
<result property="subPages" column="{siteId=page.siteId,pageId=page.PageId}" select="getPagesByParentId"/>
<result property="parentPage" column="{siteId=page.siteId,pageId=page.ParentPageId}" select="getPage"/>
</resultMap><select id="getPagesByParentId" resultMap="getPageResult">
SELECT page.* FROM page WHERE page.SiteId = #siteId# AND page.ParentPageId = #pageId# ORDER BY page.DisplayOrder
</select>
<select id="getPage" resultMap="getPageResult">
SELECT page.* FROM page WHERE SiteId=#siteId# AND PageId=#pageId#
</select>
Do you Yahoo!?
All your favorites on one personal page – Try My Yahoo!
Do you Yahoo!?
The all-new My Yahoo! – What will yours do?