ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: dynamic resultmap?
Date Thu, 23 Oct 2008 03:05:21 GMT
You can't change the resultMap/resultClass on the fly.  The best you
can do there is to use a HashMap as the resultClass and set
remapResults="true".  Then you have to figure out what got returned on
the Java side.

The includes can be *sort of* dynamic.  The trick is to ALWAYS include
the SQL fragment, and then write the fragment like this:

<sql id="pagingCode">
  <isEqual property="includePaging" compareValue="true">
    -- paging fragment here
  </isEqual>
</sql>

Of course this means more work on the Java side of things.  For
example, in this case you need to make sure that there is always an
"includePaging" property in your parameter class.

So, you can accomplish what you're asking for, but it's still kind of ugly.

Jeff Butler




On Tue, Oct 21, 2008 at 7:36 PM, Josh Joy <joshjdevl@gmail.com> wrote:
> I need two different resultmaps/resultclass.
>
> One resultclass is an "int" for when I do a select count(*).
> The second is a resultmap for the actual query.
>
> The query is being filtered (using various where clauses). I need to reuse
> this sql fragment for the paging with filtering as well as the count(*) so I
> can have this info for my web page.
>
> I also need to do this for a lot of queries. I have a reusable count sql
> fragment and paging fragment, and I could just write my sql and then for
> each sql have a count and paging which includes my fragments.
>
> Though what I would like to do, is in my DAO, to pass in a single statement
> id, though have a findCount and a findPaging which both take in the sql id
> to be executed, though includes the appropiate header as well as sets the
> appropiate result class.
>
> Is this possible?
>
> Thanks,
> Josh
>
>
>

Mime
View raw message