File tree Expand file tree Collapse file tree 3 files changed +34
-13
lines changed
src/test/java/org/apache/ibatis/submitted/ognlstatic Expand file tree Collapse file tree 3 files changed +34
-13
lines changed Original file line number Diff line number Diff line change 17
17
18
18
public interface Mapper {
19
19
20
- User getUser (Integer id );
20
+ User getUserStatic (Integer id );
21
+ User getUserIfNode (String id );
21
22
22
23
}
Original file line number Diff line number Diff line change 20
20
21
21
<mapper namespace =" org.apache.ibatis.submitted.ognlstatic.Mapper" >
22
22
23
- <select id =" getUser" resultType =" org.apache.ibatis.submitted.ognlstatic.User" >
24
- SELECT *
25
- FROM users
26
- <trim prefix =" WHERE" prefixOverrides =" AND |OR " >
27
- AND <foreach collection =" { (@org.apache.ibatis.submitted.ognlstatic.StaticClass@value) } " item =" enum"
28
- open=" name IN (" close =" ) " separator =" , " >#{enum}</foreach >
29
- AND id = #{id}
30
- </trim >
31
-
32
- </select >
23
+ <select id =" getUserStatic" resultType =" org.apache.ibatis.submitted.ognlstatic.User" >
24
+ SELECT *
25
+ FROM users
26
+ <trim prefix =" WHERE" prefixOverrides =" AND |OR " >
27
+ AND <foreach collection =" { (@org.apache.ibatis.submitted.ognlstatic.StaticClass@value) } " item =" enum"
28
+ open=" name IN (" close =" ) " separator =" , " >#{enum}</foreach >
29
+ AND id = #{id}
30
+ </trim >
31
+ </select >
32
+
33
+ <select id =" getUserIfNode" resultType =" org.apache.ibatis.submitted.ognlstatic.User" >
34
+ select * from users
35
+ <if test =" value not in {null, ''}" >
36
+ where name = #{value}
37
+ </if >
38
+ </select >
33
39
34
40
</mapper >
Original file line number Diff line number Diff line change 25
25
import org .apache .ibatis .session .SqlSessionFactoryBuilder ;
26
26
import org .junit .Assert ;
27
27
import org .junit .BeforeClass ;
28
+ import org .junit .Ignore ;
28
29
import org .junit .Test ;
29
30
30
31
public class OgnlStaticTest {
@@ -57,15 +58,28 @@ public static void setUp() throws Exception {
57
58
* There are two parameter mappings but DefaulParameterHandler maps them both to input paremeter (integer)
58
59
*/
59
60
@ Test // see issue #448
60
- public void shouldGetAUser () {
61
+ public void shouldGetAUserStatic () {
61
62
SqlSession sqlSession = sqlSessionFactory .openSession ();
62
63
try {
63
64
Mapper mapper = sqlSession .getMapper (Mapper .class );
64
- User user = mapper .getUser (1 );
65
+ User user = mapper .getUserStatic (1 );
65
66
Assert .assertEquals ("User1" , user .getName ());
66
67
} finally {
67
68
sqlSession .close ();
68
69
}
69
70
}
70
71
72
+ @ Ignore
73
+ @ Test // see issue #61
74
+ public void shouldGetAUserWithIfNode () {
75
+ SqlSession sqlSession = sqlSessionFactory .openSession ();
76
+ try {
77
+ Mapper mapper = sqlSession .getMapper (Mapper .class );
78
+ User user = mapper .getUserIfNode ("User1" );
79
+ Assert .assertEquals ("User1" , user .getName ());
80
+ } finally {
81
+ sqlSession .close ();
82
+ }
83
+ }
84
+
71
85
}
You can’t perform that action at this time.
0 commit comments