Skip to content

Commit e042979

Browse files
authored
Merge pull request #2795 from hazendaz/formatting
[ci] formatting
2 parents a451fbd + 689ab30 commit e042979

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+431
-399
lines changed

src/main/java/org/apache/ibatis/transaction/Transaction.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,37 +19,42 @@
1919
import java.sql.SQLException;
2020

2121
/**
22-
* Wraps a database connection.
23-
* Handles the connection lifecycle that comprises: its creation, preparation, commit/rollback and close.
22+
* Wraps a database connection. Handles the connection lifecycle that comprises: its creation, preparation,
23+
* commit/rollback and close.
2424
*
2525
* @author Clinton Begin
2626
*/
2727
public interface Transaction {
2828

2929
/**
3030
* Retrieve inner database connection.
31+
*
3132
* @return DataBase connection
33+
*
3234
* @throws SQLException
3335
* the SQL exception
3436
*/
3537
Connection getConnection() throws SQLException;
3638

3739
/**
3840
* Commit inner database connection.
41+
*
3942
* @throws SQLException
4043
* the SQL exception
4144
*/
4245
void commit() throws SQLException;
4346

4447
/**
4548
* Rollback inner database connection.
49+
*
4650
* @throws SQLException
4751
* the SQL exception
4852
*/
4953
void rollback() throws SQLException;
5054

5155
/**
5256
* Close inner database connection.
57+
*
5358
* @throws SQLException
5459
* the SQL exception
5560
*/
@@ -59,6 +64,7 @@ public interface Transaction {
5964
* Get transaction timeout if set.
6065
*
6166
* @return the timeout
67+
*
6268
* @throws SQLException
6369
* the SQL exception
6470
*/

src/main/java/org/apache/ibatis/transaction/TransactionFactory.java

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ public interface TransactionFactory {
3131

3232
/**
3333
* Sets transaction factory custom properties.
34+
*
3435
* @param props
3536
* the new properties
3637
*/
@@ -40,18 +41,28 @@ default void setProperties(Properties props) {
4041

4142
/**
4243
* Creates a {@link Transaction} out of an existing connection.
43-
* @param conn Existing database connection
44+
*
45+
* @param conn
46+
* Existing database connection
47+
*
4448
* @return Transaction
49+
*
4550
* @since 3.1.0
4651
*/
4752
Transaction newTransaction(Connection conn);
4853

4954
/**
5055
* Creates a {@link Transaction} out of a datasource.
51-
* @param dataSource DataSource to take the connection from
52-
* @param level Desired isolation level
53-
* @param autoCommit Desired autocommit
56+
*
57+
* @param dataSource
58+
* DataSource to take the connection from
59+
* @param level
60+
* Desired isolation level
61+
* @param autoCommit
62+
* Desired autocommit
63+
*
5464
* @return Transaction
65+
*
5566
* @since 3.1.0
5667
*/
5768
Transaction newTransaction(DataSource dataSource, TransactionIsolationLevel level, boolean autoCommit);

src/main/java/org/apache/ibatis/transaction/jdbc/JdbcTransaction.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,10 +27,9 @@
2727
import org.apache.ibatis.transaction.TransactionException;
2828

2929
/**
30-
* {@link Transaction} that makes use of the JDBC commit and rollback facilities directly.
31-
* It relies on the connection retrieved from the dataSource to manage the scope of the transaction.
32-
* Delays connection retrieval until getConnection() is called.
33-
* Ignores commit or rollback requests when autocommit is on.
30+
* {@link Transaction} that makes use of the JDBC commit and rollback facilities directly. It relies on the connection
31+
* retrieved from the dataSource to manage the scope of the transaction. Delays connection retrieval until
32+
* getConnection() is called. Ignores commit or rollback requests when autocommit is on.
3433
*
3534
* @author Clinton Begin
3635
*
@@ -50,7 +49,8 @@ public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, bo
5049
this(ds, desiredLevel, desiredAutoCommit, false);
5150
}
5251

53-
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit, boolean skipSetAutoCommitOnClose) {
52+
public JdbcTransaction(DataSource ds, TransactionIsolationLevel desiredLevel, boolean desiredAutoCommit,
53+
boolean skipSetAutoCommitOnClose) {
5454
dataSource = ds;
5555
level = desiredLevel;
5656
autoCommit = desiredAutoCommit;
@@ -111,9 +111,10 @@ protected void setDesiredAutoCommit(boolean desiredAutoCommit) {
111111
} catch (SQLException e) {
112112
// Only a very poorly implemented driver would fail here,
113113
// and there's not much we can do about that.
114-
throw new TransactionException("Error configuring AutoCommit. "
115-
+ "Your driver may not support getAutoCommit() or setAutoCommit(). "
116-
+ "Requested setting: " + desiredAutoCommit + ". Cause: " + e, e);
114+
throw new TransactionException(
115+
"Error configuring AutoCommit. " + "Your driver may not support getAutoCommit() or setAutoCommit(). "
116+
+ "Requested setting: " + desiredAutoCommit + ". Cause: " + e,
117+
e);
117118
}
118119
}
119120

@@ -132,8 +133,7 @@ protected void resetAutoCommit() {
132133
}
133134
} catch (SQLException e) {
134135
if (log.isDebugEnabled()) {
135-
log.debug("Error resetting autocommit to true "
136-
+ "before closing the connection. Cause: " + e);
136+
log.debug("Error resetting autocommit to true " + "before closing the connection. Cause: " + e);
137137
}
138138
}
139139
}

src/main/java/org/apache/ibatis/transaction/managed/ManagedTransaction.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,10 +26,9 @@
2626
import org.apache.ibatis.transaction.Transaction;
2727

2828
/**
29-
* {@link Transaction} that lets the container manage the full lifecycle of the transaction.
30-
* Delays connection retrieval until getConnection() is called.
31-
* Ignores all commit or rollback requests.
32-
* By default, it closes the connection but can be configured not to do it.
29+
* {@link Transaction} that lets the container manage the full lifecycle of the transaction. Delays connection retrieval
30+
* until getConnection() is called. Ignores all commit or rollback requests. By default, it closes the connection but
31+
* can be configured not to do it.
3332
*
3433
* @author Clinton Begin
3534
*

src/main/java/org/apache/ibatis/transaction/managed/ManagedTransactionFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ public Transaction newTransaction(Connection conn) {
5353
@Override
5454
public Transaction newTransaction(DataSource ds, TransactionIsolationLevel level, boolean autoCommit) {
5555
// Silently ignores autocommit and isolation level, as managed transactions are entirely
56-
// controlled by an external manager. It's silently ignored so that
56+
// controlled by an external manager. It's silently ignored so that
5757
// code remains portable between managed and unmanaged configurations.
5858
return new ManagedTransaction(ds, level, closeConnection);
5959
}

src/main/java/org/apache/ibatis/type/Alias.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,15 +23,16 @@
2323

2424
/**
2525
* The annotation that specify alias name.
26-
*
2726
* <p>
2827
* <b>How to use:</b>
28+
*
2929
* <pre>
3030
* &#064;Alias("Email")
3131
* public class UserEmail {
3232
* // ...
3333
* }
3434
* </pre>
35+
*
3536
* @author Clinton Begin
3637
*/
3738
@Documented

src/main/java/org/apache/ibatis/type/BaseTypeHandler.java

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,9 +26,9 @@
2626
/**
2727
* The base {@link TypeHandler} for references a generic type.
2828
* <p>
29-
* Important: Since 3.5.0, This class never call the {@link ResultSet#wasNull()} and
30-
* {@link CallableStatement#wasNull()} method for handling the SQL {@code NULL} value.
31-
* In other words, {@code null} value handling should be performed on subclass.
29+
* Important: Since 3.5.0, This class never call the {@link ResultSet#wasNull()} and {@link CallableStatement#wasNull()}
30+
* method for handling the SQL {@code NULL} value. In other words, {@code null} value handling should be performed on
31+
* subclass.
3232
* </p>
3333
*
3434
* @author Clinton Begin
@@ -48,6 +48,7 @@ public abstract class BaseTypeHandler<T> extends TypeReference<T> implements Typ
4848
*
4949
* @param c
5050
* the new configuration
51+
*
5152
* @deprecated Since 3.5.0 - See https://github.com/mybatis/mybatis-3/issues/1203. This property will remove future.
5253
*/
5354
@Deprecated
@@ -65,16 +66,16 @@ public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbc
6566
ps.setNull(i, jdbcType.TYPE_CODE);
6667
} catch (SQLException e) {
6768
throw new TypeException("Error setting null for parameter #" + i + " with JdbcType " + jdbcType + " . "
68-
+ "Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. "
69-
+ "Cause: " + e, e);
69+
+ "Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. "
70+
+ "Cause: " + e, e);
7071
}
7172
} else {
7273
try {
7374
setNonNullParameter(ps, i, parameter, jdbcType);
7475
} catch (Exception e) {
7576
throw new TypeException("Error setting non null for parameter #" + i + " with JdbcType " + jdbcType + " . "
76-
+ "Try setting a different JdbcType for this parameter or a different configuration property. "
77-
+ "Cause: " + e, e);
77+
+ "Try setting a different JdbcType for this parameter or a different configuration property. " + "Cause: "
78+
+ e, e);
7879
}
7980
}
8081
}
@@ -84,7 +85,8 @@ public T getResult(ResultSet rs, String columnName) throws SQLException {
8485
try {
8586
return getNullableResult(rs, columnName);
8687
} catch (Exception e) {
87-
throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set. Cause: " + e, e);
88+
throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set. Cause: " + e,
89+
e);
8890
}
8991
}
9092

@@ -93,7 +95,8 @@ public T getResult(ResultSet rs, int columnIndex) throws SQLException {
9395
try {
9496
return getNullableResult(rs, columnIndex);
9597
} catch (Exception e) {
96-
throw new ResultMapException("Error attempting to get column #" + columnIndex + " from result set. Cause: " + e, e);
98+
throw new ResultMapException("Error attempting to get column #" + columnIndex + " from result set. Cause: " + e,
99+
e);
97100
}
98101
}
99102

@@ -102,11 +105,13 @@ public T getResult(CallableStatement cs, int columnIndex) throws SQLException {
102105
try {
103106
return getNullableResult(cs, columnIndex);
104107
} catch (Exception e) {
105-
throw new ResultMapException("Error attempting to get column #" + columnIndex + " from callable statement. Cause: " + e, e);
108+
throw new ResultMapException(
109+
"Error attempting to get column #" + columnIndex + " from callable statement. Cause: " + e, e);
106110
}
107111
}
108112

109-
public abstract void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException;
113+
public abstract void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType)
114+
throws SQLException;
110115

111116
/**
112117
* Gets the nullable result.
@@ -115,7 +120,9 @@ public T getResult(CallableStatement cs, int columnIndex) throws SQLException {
115120
* the rs
116121
* @param columnName
117122
* Column name, when configuration <code>useColumnLabel</code> is <code>false</code>
123+
*
118124
* @return the nullable result
125+
*
119126
* @throws SQLException
120127
* the SQL exception
121128
*/

src/main/java/org/apache/ibatis/type/BigDecimalTypeHandler.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,20 +33,17 @@ public void setNonNullParameter(PreparedStatement ps, int i, BigDecimal paramete
3333
}
3434

3535
@Override
36-
public BigDecimal getNullableResult(ResultSet rs, String columnName)
37-
throws SQLException {
36+
public BigDecimal getNullableResult(ResultSet rs, String columnName) throws SQLException {
3837
return rs.getBigDecimal(columnName);
3938
}
4039

4140
@Override
42-
public BigDecimal getNullableResult(ResultSet rs, int columnIndex)
43-
throws SQLException {
41+
public BigDecimal getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
4442
return rs.getBigDecimal(columnIndex);
4543
}
4644

4745
@Override
48-
public BigDecimal getNullableResult(CallableStatement cs, int columnIndex)
49-
throws SQLException {
46+
public BigDecimal getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
5047
return cs.getBigDecimal(columnIndex);
5148
}
5249
}

src/main/java/org/apache/ibatis/type/BigIntegerTypeHandler.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,8 @@
2828
public class BigIntegerTypeHandler extends BaseTypeHandler<BigInteger> {
2929

3030
@Override
31-
public void setNonNullParameter(PreparedStatement ps, int i, BigInteger parameter, JdbcType jdbcType) throws SQLException {
31+
public void setNonNullParameter(PreparedStatement ps, int i, BigInteger parameter, JdbcType jdbcType)
32+
throws SQLException {
3233
ps.setBigDecimal(i, new BigDecimal(parameter));
3334
}
3435

0 commit comments

Comments
 (0)