You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Oscar Picasso <os...@yahoo.com> on 2005/04/07 18:04:38 UTC

Bidirectional parent-child relationship and groupBy

Hi,

I have something like that:

class Category
{
  int id;
  List<Subcategory> subcategories;
  
  ..getters and setters
}

class Subcategory
{
  int id;
  Category parent;
  
  ..getters and setters
}


A groupBy in the Category resultMap loads the related subcategories. 

However while loading these subcategories, I would like each subcategory parent
to be set.

I can use lazy loading but it can set a different parent for the subcategories
under a same Category (!= identity => more objects created).

Is there a mean to do that in the result Map (set the subcategory parent to the
same Category in a group).

Currently, I do it in the dao code but I don't find this solution very clean.

Thanks.

Oscar


		
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest