01: package com.ibatis.sqlmap.engine.transaction;
02:
03: import java.sql.Connection;
04: import java.sql.SQLException;
05:
06: public class IsolationLevel {
07:
08: public static final int UNSET_ISOLATION_LEVEL = -9999;
09:
10: private int isolationLevel = UNSET_ISOLATION_LEVEL;
11: private int originalIsolationLevel = UNSET_ISOLATION_LEVEL;
12:
13: public void setIsolationLevel(int isolationLevel) {
14: this .isolationLevel = isolationLevel;
15: }
16:
17: public void applyIsolationLevel(Connection conn)
18: throws SQLException {
19: if (isolationLevel != UNSET_ISOLATION_LEVEL) {
20: originalIsolationLevel = conn.getTransactionIsolation();
21: if (isolationLevel != originalIsolationLevel) {
22: conn.setTransactionIsolation(isolationLevel);
23: }
24: }
25: }
26:
27: public void restoreIsolationLevel(Connection conn)
28: throws SQLException {
29: if (isolationLevel != originalIsolationLevel) {
30: conn.setTransactionIsolation(originalIsolationLevel);
31: }
32: }
33:
34: }
|