Configure transaction Isolation via XML ---------------------------------------
Key: IBATIS-554 URL: https://issues.apache.org/jira/browse/IBATIS-554 Project: iBatis for Java Issue Type: Improvement Components: SQL Maps Affects Versions: 2.3.3, 2.3.2, 2.3.1, 2.3.0 Environment: not relevant Reporter: Dirk Ohst In a current project we have the requirement to configure the transaction isolation level for all transactions using the XML configuration, e.g.: <transactionManager type="JDBC" commitRequired="true"> <property name="JDBC.Connection.transactionIsolation" value="2" /> <dataSource type="JNDI"> <property name="DataSource" value="jdbc/WqSqlAx4" /> </dataSource> </transactionManager> The value corresponds to the int values defined by the constants in the Connection class of Java. To realize this I have modified the class JdbcTransactionConfig in the following way, see below. It would be very nice, if this extension could be added into the next versions. Currently we use version 2.3.0 due to the requirement to use JDK 1.4.2 in context of WebSphere Portal. Best regards, Dirk /* * Copyright 2004 Clinton Begin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ibatis.sqlmap.engine.transaction.jdbc; import com.ibatis.sqlmap.engine.transaction.BaseTransactionConfig; import com.ibatis.sqlmap.engine.transaction.IsolationLevel; import com.ibatis.sqlmap.engine.transaction.Transaction; import com.ibatis.sqlmap.engine.transaction.TransactionException; import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; import java.util.Properties; public class JdbcTransactionConfig extends BaseTransactionConfig { private DataSource dataSource; private int txIso = -1; // DO added public DataSource getDataSource() { return dataSource; } public void setDataSource(DataSource ds) { this.dataSource = ds; } public void initialize(Properties props) throws SQLException, TransactionException { // TODO DO added Start String txIsoStr = props.getProperty("JDBC.Connection.transactionIsolation"); if (txIsoStr != null) { try { this.txIso = Integer.parseInt(txIsoStr); if (this.txIso != Connection.TRANSACTION_NONE && this.txIso != Connection.TRANSACTION_READ_COMMITTED && this.txIso != Connection.TRANSACTION_READ_UNCOMMITTED && this.txIso != Connection.TRANSACTION_REPEATABLE_READ && this.txIso != Connection.TRANSACTION_SERIALIZABLE) { this.txIso = -1; throw new TransactionException("iBatis: JdbcTransactionConfig.initialize(): wrong transactionIsolationLevel: " + txIsoStr); } } catch (NumberFormatException e) { // do nothing } } // DO added End } public Transaction newTransaction(int transactionIsolation) throws SQLException, TransactionException { // TODO DO added Start int isoLevel = transactionIsolation; if (isoLevel == IsolationLevel.UNSET_ISOLATION_LEVEL) { if (txIso != -1) { isoLevel = txIso; } } // DO added end return new JdbcTransaction(dataSource, isoLevel); } } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.