//
/**获取数据库连接(线程绑定的)*/
protected TransactionObject doGetConnection(final JdbcTransactionStatus defStatus) throws SQLException {
LocalDataSourceHelper localHelper = (LocalDataSourceHelper) DataSourceUtils.getDataSourceHelper();
ConnectionSequence connSeq = localHelper.getConnectionSequence(this.getDataSource());
ConnectionHolder holder = connSeq.currentHolder();
if (holder.isOpen() == false || holder.hasTransaction() == false) {
defStatus.markNewConnection();/*新事物,新连接*/
}
holder.requested();
//下面两行代码用于保存当前Connection的隔离级别,并且设置新的隔离级别。
int isolationLevel = holder.getConnection().getTransactionIsolation();
Isolation level = null;
if (defStatus.getIsolationLevel() != Isolation.DEFAULT) {
holder.getConnection().setTransactionIsolation(defStatus.getIsolationLevel().ordinal());
level = Isolation.valueOf(isolationLevel);
}
//
return new TransactionObject(holder, level, this.getDataSource());
}