iBATIS does not have a simple API for determining if a statement
exists - so there's some difficulty with this idea.

This reminds me of the design principle "prefer polymorphism over
instanceof".  It seems to me that you could extend a generic DAO
implementation with a vendor specific implementation and override just
the methods that have vendor specific SQL.  You would also have to
configure Spring so that you could pull out the vendor specific
implementation that you need.  This seems easier to me - but I may not
understand the entirety of what you're trying to accomplish.

Jeff Butler

On Mon, Jan 12, 2009 at 3:19 AM, Ben Shory <be...@sapiens.com> wrote:
> It might be better to write a plugin that manipulates the generated
> method?
>
> -----Original Message-----
> From: Ben Shory [mailto:be...@sapiens.com]
> Sent: Monday, January 12, 2009 11:13 AM
> To: user-java@ibatis.apache.org
> Subject: SQL selector
>
> Hi,
> Before any statement execution, I would like to first check if it has a
> vendor specific implementation and execute it if so or the default one
> if not.
> My DAOs are generated as spring dao with ibator.
> I thought of doing something like -
>
>        String stmtId = "table"+spec_postfix+".countByExample";
>        if(!statementExists(stmtId)) {
>                stmtId = "table.countByExample";
>        }
>        Integer count = (Integer)
> getSqlMapClientTemplate().queryForObject(stmtId,
>                        example);
>        return count;
>
> Is this a good approach?
> Would I have to override SpringDAOTemplae?
>
>

Reply via email to