Re: Pagination with nested results

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Pagination with nested results

Simon
Hi, in your second example, do you need to specify a specific result
map for ProjectUser table rows?  Does mybaits in this case make 2
calls to the db, one to get the task, and one to get the user, right
after?  Or are you ding it with one piece of sql?  Would be good to
see the sql too (to see how to do this kind of stuff).

I have heard of lazy loading, but dont know when or how it might work
(i.e. what triggers it), and haven't seen any examples which use it.

On Aug 27, 1:26 pm, Dan Persa <[hidden email]> wrote:

> Hello,
>
> I have the following two alternative mappings for a select:
>
> <resultMap id="taskResultMap" type="Task">
>         <id property="id" column="TASK_ID" />
>         <result property="title" column="TASK_TITLE"/>
>         <!-- <association property="creator" column="CREATOR_USER_ID"
> javaType="ProjectUser" select="selectProjectUserById"/> -->
>         <association property="creator" javaType="ProjectUser"
> resultMap="creatorUserResultMap"/>
> </resultMap>
>
> <resultMap id="taskResultMap" type="Task">
>         <id property="id" column="TASK_ID" />
>         <result property="title" column="TASK_TITLE"/>
>         <association property="creator" column="CREATOR_USER_ID"
> javaType="ProjectUser" select="selectProjectUserById"/>
> </resultMap>
>
> The only difference is the association type:
>     - the first one uses nested selects
>     - the second nested results
> both of them are working well when I don't use pagiantion (RowBounds)
>
> When I use row bounds, the first mapping gives me the exception:
>
> org.apache.ibatis.executor.ExecutorException: Mapped Statements with
> nested result mappings cannot be safely constrained by RowBounds.
>
> The second mapping works well, but makes n+1 selects for every join...
>
> Does anyone know how to make the pagination with the nested results
> mapping?
>
> Thanks,
>     Dan