ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ritu Kedia" <ritu.ke...@mphasis.com>
Subject External Transaction Management
Date Mon, 13 Jun 2005 14:47:31 GMT
Hi All,

 

I am investigating how iBATIS supports External Tx. We are using iBATIS
DataMapper (SQLMaps) in our DAO layer (Please note we are not using iBATIS
DAO framework). 

 

The container/framework within which our DAOs would be used is not yet
finalized. We would be using either EJB or Spring.

 

Currently our DAO implementation uses com.ibatis.sqlmap.client.SqlMapClient
and com.ibatis.sqlmap.client.SqlMapSession for any DB operations.

For e.g.

Insert a row in DB:

            Reader configReader = Resources.getResourceAsReader
(Constants.SQLMap_Config_File);

            SqlMapClient  iBatisSqlMapClient =
SqlMapClientBuilder.buildSqlMapClient(configReader);

            SqlMapSession  iBatisSqlMapSession =
iBatisSqlMapClient.openSession(); 

            int key =
((Integer)iBatisSqlMapSession.insert(component.getCreateProcedureId(),
detail)).intValue(); 

 

SQLMapConfig.xml for the above e.g.:

    <transactionManager type="JDBC">

        <dataSource type="SIMPLE" >

            <property name="JDBC.Driver"
value="oracle.jdbc.driver.OracleDriver"/>

            <property name="JDBC.ConnectionURL"
value="jdbc:oracle:thin:@localhost:1521:orcl"/>

            <property name="JDBC.Username" value="user"/>

            <property name="JDBC.Password" value="password"/>

            <property name="JDBC.DefaultAutoCommit" value="true"/>

        </dataSource>

    </transactionManager>

 

Now if we want to call these DAOs from an EJB/ Service defined in J2EE
container/ Spring Framework respectively, then would the above insert code
work with some simple config changes in the SQLMapConfig.xml?

 

I believe the answer is No. In case of EJB, if the transactionManager type
is JDBC then I believe the SQLMapSession would internally try to commit the
transaction on the JNDI data source, which is configured as Container
Managed, and this would result in an exception being thrown by the J2EE
container.

Using declarative transaction feature of EJB Container, how would we have to
modify the above insert code?

 

For Spring, I saw Equinox-Ibatis 1.3
(https://equinox.dev.java.net/files/documents/1901/11872/equinox-ibatis-1.3.
zip )

But I could not get this sample running. My tomcat server is running on port
8082 whereas Equinox is somehow always creating the tomcat server.xml file
with port 8080. Don't know whats the problem(I have replaced every
occurrence of 8080 in any file under equinox-ibatis folder with 8082) . 

I did not find any documentation either on what exactly the code sample is
doing. 

Is the SQLMapClientTemplate part of the iBATIS DAO Framework? Does anyone
know where can I find the documentation for equinox-ibatis code?

 

Any reply would be very much appreciated.

 

Thanks and Regards,

Ritu

 

 


Mime
View raw message