Skip to content

Commit b3269d6

Browse files
committed
Rollback r3820 (http://code.google.com/p/mybatis/issues/detail?id=21 ). Change delayed till 3.1.x
1 parent fd99bdd commit b3269d6

20 files changed

+343
-784
lines changed

src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,11 @@ public MappedStatement addMappedStatement(
212212
boolean flushCache,
213213
boolean useCache,
214214
KeyGenerator keyGenerator,
215-
String keyProperty,
216-
String databaseId) {
215+
String keyProperty) {
217216
id = applyCurrentNamespace(id);
218217
boolean isSelect = sqlCommandType == SqlCommandType.SELECT;
219218

220-
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, id, sqlSource, sqlCommandType, databaseId);
219+
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, id, sqlSource, sqlCommandType);
221220
statementBuilder.resource(resource);
222221
statementBuilder.fetchSize(fetchSize);
223222
statementBuilder.statementType(statementType);
@@ -230,7 +229,7 @@ public MappedStatement addMappedStatement(
230229
setStatementCache(isSelect, flushCache, useCache, currentCache, statementBuilder);
231230

232231
MappedStatement statement = statementBuilder.build();
233-
configuration.addMappedStatement(statement, databaseId);
232+
configuration.addMappedStatement(statement);
234233
return statement;
235234
}
236235

src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ private void parseStatement(Method method) {
281281
flushCache,
282282
useCache,
283283
keyGenerator,
284-
keyProperty,
285-
null);
284+
keyProperty);
286285
}
287286
}
288287

@@ -499,7 +498,7 @@ private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, St
499498

500499
assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
501500
fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
502-
resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty, null);
501+
resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty);
503502

504503
id = assistant.applyCurrentNamespace(id);
505504

src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
import java.io.Reader;
55
import java.util.Properties;
66

7-
import javax.sql.DataSource;
8-
97
import org.apache.ibatis.builder.BaseBuilder;
108
import org.apache.ibatis.builder.BuilderException;
119
import org.apache.ibatis.datasource.DataSourceFactory;
1210
import org.apache.ibatis.executor.ErrorContext;
1311
import org.apache.ibatis.io.Resources;
14-
import org.apache.ibatis.mapping.DatabaseIdProvider;
15-
import org.apache.ibatis.mapping.DefaultDatabaseIdProvider;
1612
import org.apache.ibatis.mapping.Environment;
1713
import org.apache.ibatis.parsing.XNode;
1814
import org.apache.ibatis.parsing.XPathParser;
@@ -194,35 +190,15 @@ private void environmentsElement(XNode context) throws Exception {
194190
if (isSpecifiedEnvironment(id)) {
195191
TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
196192
DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
197-
DataSource dataSource = dsFactory.getDataSource();
198193
Environment.Builder environmentBuilder = new Environment.Builder(id)
199-
.transactionFactory(txFactory)
200-
.dataSource(dataSource);
201-
databaseElement(child.evalNode("database"), environmentBuilder);
194+
.transactionFactory(txFactory)
195+
.dataSource(dsFactory.getDataSource());
202196
configuration.setEnvironment(environmentBuilder.build());
203197
}
204198
}
205199
}
206200
}
207201

208-
private void databaseElement(XNode context, Environment.Builder builder) throws Exception {
209-
if (context != null) {
210-
String id = context.getStringAttribute("id");
211-
String type = context.getStringAttribute("provider");
212-
if (id != null && type != null) {
213-
throw new BuilderException("Database element may provide a database id or a provider, but not both.");
214-
}
215-
if (id != null) {
216-
builder.databaseId(id);
217-
} else if (type != null) {
218-
DatabaseIdProvider databaseIdProvider = (DatabaseIdProvider) resolveClass(type).newInstance();
219-
Properties props = context.getChildrenAsProperties();
220-
databaseIdProvider.setProperties(props);
221-
builder.databaseIdProvider(databaseIdProvider);
222-
}
223-
}
224-
}
225-
226202
private TransactionFactory transactionManagerElement(XNode context) throws Exception {
227203
if (context != null) {
228204
String type = context.getStringAttribute("type");
@@ -245,6 +221,7 @@ private DataSourceFactory dataSourceElement(XNode context) throws Exception {
245221
throw new BuilderException("Environment declaration requires a DataSourceFactory.");
246222
}
247223

224+
248225
private void typeHandlerElement(XNode parent) throws Exception {
249226
if (parent != null) {
250227
for (XNode child : parent.getChildren()) {

src/main/java/org/apache/ibatis/builder/xml/XMLStatementBuilder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public void parseStatementNode() {
3636
Class<?> parameterTypeClass = resolveClass(parameterType);
3737
String resultMap = context.getStringAttribute("resultMap");
3838
String resultType = context.getStringAttribute("resultType");
39-
String databaseId = context.getStringAttribute("databaseId");
4039

4140
Class<?> resultTypeClass = resolveClass(resultType);
4241
String resultSetType = context.getStringAttribute("resultSetType");
@@ -66,7 +65,7 @@ public void parseStatementNode() {
6665

6766
builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
6867
fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
69-
resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty, databaseId);
68+
resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty);
7069
}
7170

7271

@@ -125,7 +124,6 @@ public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
125124
StatementType statementType = StatementType.valueOf(nodeToHandle.getStringAttribute("statementType", StatementType.PREPARED.toString()));
126125
String keyProperty = nodeToHandle.getStringAttribute("keyProperty");
127126
String parameterType = parent.getStringAttribute("parameterType");
128-
String databaseId = parent.getStringAttribute("databaseId");
129127
boolean executeBefore = "BEFORE".equals(nodeToHandle.getStringAttribute("order", "AFTER"));
130128
Class<?> parameterTypeClass = resolveClass(parameterType);
131129

@@ -146,7 +144,7 @@ public void handleNode(XNode nodeToHandle, List<SqlNode> targetContents) {
146144

147145
builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
148146
fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
149-
resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty, databaseId);
147+
resultSetTypeEnum, flushCache, useCache, keyGenerator, keyProperty);
150148

151149
id = builderAssistant.applyCurrentNamespace(id);
152150

src/main/java/org/apache/ibatis/builder/xml/dynamic/DynamicContext.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6+
import ognl.OgnlContext;
67
import ognl.OgnlException;
78
import ognl.OgnlRuntime;
89
import ognl.PropertyAccessor;
@@ -13,7 +14,6 @@
1314
public class DynamicContext {
1415

1516
public static final String PARAMETER_OBJECT_KEY = "_parameter";
16-
public static final String ENVIRONMENT_KEY = "_environment";
1717

1818
static {
1919
OgnlRuntime.setPropertyAccessor(ContextMap.class, new ContextAccessor());
@@ -31,7 +31,6 @@ public DynamicContext(Configuration configuration, Object parameterObject) {
3131
bindings = new ContextMap(null);
3232
}
3333
bindings.put(PARAMETER_OBJECT_KEY, parameterObject);
34-
bindings.put(ENVIRONMENT_KEY, configuration.getEnvironment());
3534
}
3635

3736
public Map<String, Object> getBindings() {
Lines changed: 85 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,85 @@
1-
<?xml version="1.0" encoding="UTF-8" ?>
2-
3-
<!ELEMENT configuration (properties?, settings?, typeAliases?, typeHandlers?, objectFactory?, objectWrapperFactory?, plugins?, environments?, mappers?)>
4-
5-
<!ELEMENT properties (property*)>
6-
<!ATTLIST properties
7-
resource CDATA #IMPLIED
8-
url CDATA #IMPLIED
9-
>
10-
11-
<!ELEMENT property EMPTY>
12-
<!ATTLIST property
13-
name CDATA #REQUIRED
14-
value CDATA #REQUIRED
15-
>
16-
17-
<!ELEMENT settings (setting+)>
18-
19-
<!ELEMENT setting EMPTY>
20-
<!ATTLIST setting
21-
name CDATA #REQUIRED
22-
value CDATA #REQUIRED
23-
>
24-
25-
<!ELEMENT typeAliases (typeAlias+)>
26-
27-
<!ELEMENT typeAlias EMPTY>
28-
<!ATTLIST typeAlias
29-
type CDATA #REQUIRED
30-
alias CDATA #IMPLIED
31-
>
32-
33-
<!ELEMENT typeHandlers (typeHandler+)>
34-
35-
<!ELEMENT typeHandler EMPTY>
36-
<!ATTLIST typeHandler
37-
javaType CDATA #REQUIRED
38-
jdbcType CDATA #IMPLIED
39-
handler CDATA #REQUIRED
40-
>
41-
42-
<!ELEMENT objectFactory (property*)>
43-
<!ATTLIST objectFactory
44-
type CDATA #REQUIRED
45-
>
46-
47-
<!ELEMENT objectWrapperFactory (property*)>
48-
<!ATTLIST objectWrapperFactory
49-
type CDATA #REQUIRED
50-
>
51-
52-
<!ELEMENT plugins (plugin+)>
53-
54-
<!ELEMENT plugin (property*)>
55-
<!ATTLIST plugin
56-
interceptor CDATA #REQUIRED
57-
>
58-
59-
<!ELEMENT environments (environment+)>
60-
<!ATTLIST environments
61-
default CDATA #REQUIRED
62-
>
63-
64-
<!ELEMENT environment (transactionManager,dataSource,database?)>
65-
<!ATTLIST environment
66-
id CDATA #REQUIRED
67-
>
68-
69-
<!ELEMENT transactionManager (property*)>
70-
<!ATTLIST transactionManager
71-
type CDATA #REQUIRED
72-
>
73-
74-
<!ELEMENT dataSource (property*)>
75-
<!ATTLIST dataSource
76-
type CDATA #REQUIRED
77-
>
78-
79-
<!ELEMENT database (property*)>
80-
<!ATTLIST database
81-
id CDATA #IMPLIED
82-
provider CDATA #IMPLIED
83-
>
84-
85-
<!ELEMENT mappers (mapper+)>
86-
87-
<!ELEMENT mapper EMPTY>
88-
<!ATTLIST mapper
89-
resource CDATA #IMPLIED
90-
url CDATA #IMPLIED
91-
>
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<!ELEMENT configuration (properties?, settings?, typeAliases?, typeHandlers?, objectFactory?, objectWrapperFactory?, plugins?, environments?, mappers?)>
4+
5+
<!ELEMENT properties (property*)>
6+
<!ATTLIST properties
7+
resource CDATA #IMPLIED
8+
url CDATA #IMPLIED
9+
>
10+
11+
<!ELEMENT property EMPTY>
12+
<!ATTLIST property
13+
name CDATA #REQUIRED
14+
value CDATA #REQUIRED
15+
>
16+
17+
<!ELEMENT settings (setting+)>
18+
19+
<!ELEMENT setting EMPTY>
20+
<!ATTLIST setting
21+
name CDATA #REQUIRED
22+
value CDATA #REQUIRED
23+
>
24+
25+
<!ELEMENT typeAliases (typeAlias+)>
26+
27+
<!ELEMENT typeAlias EMPTY>
28+
<!ATTLIST typeAlias
29+
type CDATA #REQUIRED
30+
alias CDATA #IMPLIED
31+
>
32+
33+
<!ELEMENT typeHandlers (typeHandler+)>
34+
35+
<!ELEMENT typeHandler EMPTY>
36+
<!ATTLIST typeHandler
37+
javaType CDATA #REQUIRED
38+
jdbcType CDATA #IMPLIED
39+
handler CDATA #REQUIRED
40+
>
41+
42+
<!ELEMENT objectFactory (property*)>
43+
<!ATTLIST objectFactory
44+
type CDATA #REQUIRED
45+
>
46+
47+
<!ELEMENT objectWrapperFactory (property*)>
48+
<!ATTLIST objectWrapperFactory
49+
type CDATA #REQUIRED
50+
>
51+
52+
<!ELEMENT plugins (plugin+)>
53+
54+
<!ELEMENT plugin (property*)>
55+
<!ATTLIST plugin
56+
interceptor CDATA #REQUIRED
57+
>
58+
59+
<!ELEMENT environments (environment+)>
60+
<!ATTLIST environments
61+
default CDATA #REQUIRED
62+
>
63+
64+
<!ELEMENT environment (transactionManager,dataSource)>
65+
<!ATTLIST environment
66+
id CDATA #REQUIRED
67+
>
68+
69+
<!ELEMENT transactionManager (property*)>
70+
<!ATTLIST transactionManager
71+
type CDATA #REQUIRED
72+
>
73+
74+
<!ELEMENT dataSource (property*)>
75+
<!ATTLIST dataSource
76+
type CDATA #REQUIRED
77+
>
78+
79+
<!ELEMENT mappers (mapper+)>
80+
81+
<!ELEMENT mapper EMPTY>
82+
<!ATTLIST mapper
83+
resource CDATA #IMPLIED
84+
url CDATA #IMPLIED
85+
>

0 commit comments

Comments
 (0)