File tree Expand file tree Collapse file tree 5 files changed +91
-5
lines changed
main/java/org/apache/ibatis/reflection
test/java/org/apache/ibatis/submitted/simplelistparameter Expand file tree Collapse file tree 5 files changed +91
-5
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2009-2015 the original author or authors.
2
+ * Copyright 2009-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -119,12 +119,12 @@ private Type getGenericGetterType(String propertyName) {
119
119
Field _method = MethodInvoker .class .getDeclaredField ("method" );
120
120
_method .setAccessible (true );
121
121
Method method = (Method ) _method .get (invoker );
122
- return method . getGenericReturnType ( );
122
+ return TypeParameterResolver . resolveReturnType ( method , reflector . getType () );
123
123
} else if (invoker instanceof GetFieldInvoker ) {
124
124
Field _field = GetFieldInvoker .class .getDeclaredField ("field" );
125
125
_field .setAccessible (true );
126
126
Field field = (Field ) _field .get (invoker );
127
- return field . getGenericType ( );
127
+ return TypeParameterResolver . resolveFieldType ( field , reflector . getType () );
128
128
}
129
129
} catch (NoSuchFieldException e ) {
130
130
} catch (IllegalAccessException e ) {
Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2009-2015 the original author or authors.
2
+ * Copyright 2009-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -23,4 +23,10 @@ public interface CarMapper {
23
23
24
24
@ Select ({ "select name from car where doors = #{doors[1]}" })
25
25
List <Car > getCar (Car car );
26
+
27
+ @ Select ({ "select name from car where doors = #{doors1[1]}" })
28
+ List <Rv > getRv1 (Rv rv );
29
+
30
+ @ Select ({ "select name from car where doors = #{doors2[1]}" })
31
+ List <Rv > getRv2 (Rv rv );
26
32
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright 2009-2016 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package org .apache .ibatis .submitted .simplelistparameter ;
17
+
18
+ public class Rv extends Vehicle <String > {
19
+ }
Original file line number Diff line number Diff line change 1
1
/**
2
- * Copyright 2009-2015 the original author or authors.
2
+ * Copyright 2009-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -65,4 +65,31 @@ public void shouldGetACar() throws Exception {
65
65
}
66
66
}
67
67
68
+ @ Test
69
+ public void shouldResolveGenericFieldGetterType () throws Exception {
70
+ SqlSession sqlSession = sqlSessionFactory .openSession ();
71
+ try {
72
+ CarMapper carMapper = sqlSession .getMapper (CarMapper .class );
73
+ Rv rv = new Rv ();
74
+ rv .doors1 = Arrays .asList (new String [] {"2" , "4" });
75
+ List <Rv > rvs = carMapper .getRv1 (rv );
76
+ Assert .assertNotNull (rvs );
77
+ } finally {
78
+ sqlSession .close ();
79
+ }
80
+ }
81
+
82
+ @ Test
83
+ public void shouldResolveGenericMethodGetterType () throws Exception {
84
+ SqlSession sqlSession = sqlSessionFactory .openSession ();
85
+ try {
86
+ CarMapper carMapper = sqlSession .getMapper (CarMapper .class );
87
+ Rv rv = new Rv ();
88
+ rv .setDoors2 (Arrays .asList (new String [] {"2" , "4" }));
89
+ List <Rv > rvs = carMapper .getRv2 (rv );
90
+ Assert .assertNotNull (rvs );
91
+ } finally {
92
+ sqlSession .close ();
93
+ }
94
+ }
68
95
}
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright 2009-2016 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package org .apache .ibatis .submitted .simplelistparameter ;
17
+
18
+ import java .util .List ;
19
+
20
+ public class Vehicle <T > {
21
+ public T name ;
22
+
23
+ public List <T > doors1 ;
24
+
25
+ private List <T > doors2 ;
26
+
27
+ public List <T > getDoors2 () {
28
+ return doors2 ;
29
+ }
30
+
31
+ public void setDoors2 (List <T > doors2 ) {
32
+ this .doors2 = doors2 ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments