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 Ma...@pruftechnik.com on 2006/02/02 10:11:52 UTC

use dao and sqlmaps

Hello,

I will use dao with sqlmaps. I also want to configure more than one 
database connections. 
Therefore I add some contexts to the dao config (dao.xml) file.

<dao-config>

  <context id="DB_1">

    <transactionManager type="SQLMAP">
      <property name="SqlMapConfig" 
value="com/domain/dao/sqlmap/SqlMapConfig_1.xml"/>
    </transactionManager>

    <dao interface="com.domain.dao.OrderDao" 
implementation="com.domain.dao.jdbc.JdbcOrderDao"/>
    ...
  </context>

  <context id="DB_2">

    <transactionManager type="SQLMAP">
      <property name="SqlMapConfig" 
value="com/domain/dao/sqlmap/SqlMapConfig_2.xml"/>
    </transactionManager>

    <dao interface="com.domain.dao.OrderDao" 
implementation="com.domain.dao.jdbc.JdbcOrderDao"/>
    ...
  </context>

... // more contexts

</dao-config>


The sql map config file(s) looks like following:

<sql-map-config>

  <properties resource="conf/omt/sqlmap/SqlMapConfig.properties" />

  <transactionManager type="JDBC">
    <dataSource type="SIMPLE">
      <property value="${driver}" name="JDBC.Driver"/>
      <property value="${url}" name="JDBC.ConnectionURL"/>
      <property value="${username}" name="JDBC.Username"/>
      <property value="${password}" name="JDBC.Password"/>
    </dataSource>
  </transactionManager>

  <sql-map resource="conf/omt/sqlmap/TreeInfo.xml" />
  ...
</sql-map-config>


Is there a mechanism to use for all dao contexts the same sql map config 
file (configure the transaction manager - db url, driver, etc.- in the 
context in the dao config file)? 
Because the files are identically apart from the url or driver.
The advantage is that I had to create only one sql map config file and 
only one dao config file.

Best regards
Manuel Rädle