You could separate your sql files into databae dependent sqlmaps and
universal sql maps. Then you could pass a database appropriate
namespace for those that are database specific. Then in you sqlmap
calls you can substitute a value.
Ex.
customer.xml (for universal sql)
--------------------------
<sqlMap namespace="Customer">
...
</sqlMap>
db2_customer.xml (for db specific sql)
--------------------------
<sqlMap namespace="DB2_Customer">
...
</sqlMap>
CustomerDaoImpl.java
--------------------------
...
return queryForList(dbSpecificNameSpacePrefix +
"Customer.getCustomerByPurchaseRatio",null);
...
...
return queryForList("Customer.getAll",null);
...
database_environment.properties
--------------------------
dbSpecificNameSpacePrefix=DB2_
Hope that helps,
Brandon
On Thu, 3 Mar 2005 15:07:19 -0500, Scott Zhu <[EMAIL PROTECTED]> wrote:
> I post a few question in the last few days. I'm at the final stage of
> evaluting iBatis for our application. This is probably one of the last
> issues we need to settle now.
>
> We want to support vendor specific queries. Again, it's being defined
> at runtime. So the current thought is, we include them in the same
> file, say in Item.xml, we have "getItemsByOrderID" query, and late we
> decide we need a db2 specific query, we add a "getItemsByOderID_DB2"
> query in there. In our DAO code, when the statement is being executed,
> we do a two-step lookup. We have knowledge on the database type then,
> so we first check to see if there's a $statement_$databaseType
> statement in the map, if not, fall back to use just $statement (kind
> like how resource look up works). My questions are:
>
> 1. I don't know if this is the best/clean way to deal with this kind
> of problems.
> 2. In iBatis, is there a way to check if a given statement exists in
> the current map?
>
> Thanks.
>