Skip to content

Commit ef734ae

Browse files
committed
#7bug修復
1 parent 0eaf3ff commit ef734ae

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

spring-boot-mybatis-rw/spring-boot-mybatis-rw-sample/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<attribute name="maven.pomderived" value="true"/>
1818
</attributes>
1919
</classpathentry>
20-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
20+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
2121
<attributes>
2222
<attribute name="maven.pomderived" value="true"/>
2323
</attributes>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4-
org.eclipse.jdt.core.compiler.compliance=1.7
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4+
org.eclipse.jdt.core.compiler.compliance=1.5
55
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
66
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
77
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8-
org.eclipse.jdt.core.compiler.source=1.7
8+
org.eclipse.jdt.core.compiler.source=1.5

spring-boot-mybatis-rw/spring-boot-mybatis-rw-starter/.settings/org.eclipse.wst.common.component

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<wb-module deploy-name="spring-boot-mybatis-rw-starter">
33
<wb-resource deploy-path="/" source-path="/src/main/java"/>
44
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
5+
<wb-resource deploy-path="/" source-path="/src/test/java"/>
56
</wb-module>
67
</project-modules>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<faceted-project>
33
<installed facet="jst.utility" version="1.0"/>
4-
<installed facet="java" version="1.8"/>
4+
<installed facet="java" version="1.5"/>
55
</faceted-project>

spring-boot-mybatis-rw/spring-boot-mybatis-rw-starter/src/main/java/org/spring/boot/mybatis/rw/starter/datasource/DataSourceProxy.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public class DataSourceProxy implements DataSource {
3030

3131
private static final Log logger = LogFactory.getLog(DataSourceProxy.class);
3232

33-
private Boolean defaultAutoCommit;
33+
private Boolean defaultAutoCommit = Boolean.TRUE;
3434

35-
private Integer defaultTransactionIsolation;
35+
private Integer defaultTransactionIsolation = 2;
3636

3737
private DataSourceRout dataSourceRout;
3838

3939
/**
40-
* Create a new LazyConnectionDataSourceProxy.
40+
* Create a new LazyConnectionDataSourceProxy.a
4141
*
4242
* @see #setTargetDataSource
4343
*/
@@ -275,7 +275,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
275275
}
276276
if (method.getName().equals("close")) {
277277
Map<String, Connection> connectionMap = ConnectionHold.CONNECTION_CONTEXT.get();
278-
Connection writeCon = connectionMap.get(ConnectionHold.WRITE);
278+
connectionMap.remove(ConnectionHold.READ);
279+
ConnectionHold.FORCE_WRITE.set(Boolean.FALSE);
280+
Connection writeCon = connectionMap.remove(ConnectionHold.WRITE);
279281
if (writeCon != null) {
280282
writeCon.close();
281283
}
@@ -288,15 +290,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
288290
// or target Connection necessary for current operation ->
289291
// invoke method on target connection.
290292
try {
291-
if (!hasTargetConnection()) {
292-
Connection conn = getTargetConnection(method);
293-
return method.invoke(conn, args);
294-
295-
} else {
296-
return method.invoke(
297-
ConnectionHold.CONNECTION_CONTEXT.get().get(ConnectionHold.CURRENT_CONNECTION.get()), args);
298-
299-
}
293+
return method.invoke(
294+
ConnectionHold.CONNECTION_CONTEXT.get().get(ConnectionHold.CURRENT_CONNECTION.get()), args);
300295
} catch (InvocationTargetException ex) {
301296
throw ex.getTargetException();
302297
}

spring-boot-mybatis-rw/spring-boot-mybatis-rw-starter/src/main/java/org/spring/boot/mybatis/rw/starter/pulgin/RWPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Object intercept(Invocation invocation) throws Throwable {
5252
}
5353
String key = ConnectionHold.WRITE;
5454

55-
if (mappedStatement.getSqlCommandType() == SqlCommandType.SELECT) {
55+
if (mappedStatement.getSqlCommandType() == SqlCommandType.SELECT && !mappedStatement.getId().endsWith("!selectKey")) {
5656
key = ConnectionHold.READ;
5757
}
5858
routeConnection(key, conn);

0 commit comments

Comments
 (0)