ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson" <agcu...@superig.com.br>
Subject How to Persist the same object in two Databases: Informix and SQL Server
Date Sun, 17 Jul 2005 14:04:32 GMT
Hi everybody,

 

            My application will use two databases: Informix and SQL Server.

I think I'll have to persist the same object in two databases and I'm trying
to configure the dao.config to support it.

Both databases will use IBatis Data Mapping and I'm using IBatis Dao.

 

Well. let me show what I'm, doing:

 

For Informix NET Provider, here is the provider config:

 

 

<provider

            name="Informix"

            description="Informix NET Provider, 2.81.0.0"

            enabled="true"

            assemblyName="IBM.Data.Informix, Version=2.81.0.0,
Culture=neutral, PublicKeyToken=7c307b91aa13d208"

            connectionClass="IBM.Data.Informix.IfxConnection" 

            commandClass="IBM.Data.Informix.IfxCommand"

            parameterClass="IBM.Data.Informix.IfxParameter"

            parameterDbTypeClass="IBM.Data.Informix.IfxType"

            parameterDbTypeProperty="IfxType"

            dataAdapterClass="IBM.Data.Informix.IfxDataAdapter"

            commandBuilderClass="IBM.Data.Informix.IfxCommandBuilder"

            usePositionalParameters = "true"

            useParameterPrefixInSql = "false"

            useParameterPrefixInParameter = "false"

            useDeriveParameters="false"

      />

 

The problem is to get the DAO context in my application, Here is the
DAO.config

 

<?xml version="1.0" encoding="utf-8"?>

<daoConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DaoConfig.xsd">

 

      <context id="SqlServerMapDao" default="true">

 

            <properties resource="../../database.config"/>

            

            <database>

                  <provider name="sqlServer1.1"/>

                  <dataSource name="iBatisNet" connectionString="data
source=${MSSQLdatasource};database=${MSSQLdatabase};user
id=${MSSQLuserid};password=${MSSQLpassword};connection
reset=false;connection lifetime=5; min pool size=1; max pool size=50"/>

            </database>       

            

            <daoSessionHandler id="SqlMap">

                  <property name="url"
value="D:\CookBooks\Persistencia\ONSA\Ons.Onsa.Persistence.Tests\bin\Debug\S
qlMapMSSQL.config"/>               

            </daoSessionHandler>

            

            <daoFactory>

                    <dao
interface="Ons.Siga.Persistencia.Interfaces.Forum.IMembroDao"
implementation="Ons.Siga.Persistencia.MapperDao.Forum.MembroSqlMapDao"/>

            </daoFactory>

            

      </context>

      

      <context id="InformixMapDao">

 

            <properties resource="../../database.config"/>

            

            <database>

                  <provider name="Informix"/>

                  <dataSource name="iBatisNetx" connectionString="User
Id=${Ifxuserid};Database=${Ifxdatabase};Host=${Ifxhost};password=${Ifxpasswo
rd};Server=${Ifxserver};Protocol=${Ifxprotocol}; Service==${Ifxservice};"/>

            </database>       

            

            <daoSessionHandler id="SqlMap">

                  <property name="url"
value="D:\CookBooks\Persistencia\ONSA\Ons.Onsa.Persistence.Tests\bin\Debug\S
qlMapInformix.config"/>                  

            </daoSessionHandler>

            

            <daoFactory>

                  <dao
interface="Ons.Siga.Persistencia.Interfaces.Forum.IMembroDao"
implementation="Ons.Siga.Persistencia.MapperDao.Forum.MembroSqlMapDao"/>

            </daoFactory>

            

      </context>  

</daoConfig>

 

 

To get the DAO context I used:

 

DaoManager.GetInstance("SqlServerMapDao");

 

And here is my database.config with properties:

 

<?xml version="1.0" encoding="utf-8" ?> 

<settings>

            

      <add key="Ifxuserid" value="informix" />

      <add key="Ifxpassword" value="informix" />

      <add key="Ifxdatabase" value="bd_tecndes" />

      <add key="Ifxhost" value="melbourne" />

      <add key="Ifxserver" value="ol_melbourne" />

      <add key="Ifxprotocol" value="olsoctcp" />

      <add key="Ifxservice" value="turbo" />

      

      <add key="MSSQLdatasource" value="MELBOURNE" />

      <add key="MSSQLdatabase" value="IBatisNet" />

      <add key="MSSQLuserid" value="sa" />

      <add key="MSSQLpassword" value="" />

            

      <add key="selectKey" value="select @@IDENTITY as value" />

      <add key="directory" value="Maps" />

      <add key="useStatementNamespaces" value="false" />

</settings>

 

I don't know why when I try to get the SQLServer, the DAOManager gets the
Informix Properties

Anybody knows how to do it?

 

If I don't have to persist to one of the databases, is there a way to let
IBatis choose the Context automatically?

 

Thanks,

Anderson

 

 


Mime
View raw message