Skip to content

Commit 01c0c2d

Browse files
committed
Closes mybatis#145. Nothing to do. Inline params syntax was changed more that
we wanted!
1 parent b0fac1c commit 01c0c2d

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

src/test/java/org/apache/ibatis/submitted/sptests/CreateDB.sql

+6
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,9 @@ begin atomic
142142
open cur;
143143
end
144144
go
145+
146+
create procedure sptest.echoDate(in inputDate date, out outputDate date)
147+
begin atomic
148+
set outputDate = inputDate;
149+
end
150+
go

src/test/java/org/apache/ibatis/submitted/sptests/SPMapper.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface SPMapper {
3232
Object adderAsSelect(Parameter parameter);
3333

3434
void adderAsUpdate(Parameter parameter);
35-
35+
3636
void adderWithParameterMap(Map<String, Object> parameter);
3737

3838
Name getName(Integer id);
@@ -47,6 +47,8 @@ public interface SPMapper {
4747

4848
List<Name> getNamesAndItemsLinkedById(int id);
4949

50+
Object echoDate(Map<String, Object> parameter); // issue #145
51+
5052
// annotated
5153
@Select({ "{call sptest.adder(", "#{addend1,jdbcType=INTEGER,mode=IN},", "#{addend2,jdbcType=INTEGER,mode=IN},", "#{sum,jdbcType=INTEGER,mode=OUT})}" })
5254
@Options(statementType = StatementType.CALLABLE)

src/test/java/org/apache/ibatis/submitted/sptests/SPMapper.xml

+9-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
<update id="adderWithParameterMap" parameterMap="testParameterMap" statementType="CALLABLE">
8787
{call sptest.adder(?, ?, ?)}
8888
</update>
89-
89+
9090
<select id="getName" parameterType="java.lang.Integer" statementType="CALLABLE"
9191
resultMap="nameResult">
9292
{call sptest.getname(
@@ -120,5 +120,13 @@
120120
<select id="getNamesAndItemsLinkedById" statementType="CALLABLE" resultSets="names,items" resultMap="nameResultLinkedNoMatchingInfo">
121121
{call sptest.getnamesanditemsbyid(#{id,jdbcType=INTEGER,mode=IN})}
122122
</select>
123+
124+
<!-- issue #145 -->
125+
<select id="echoDate" parameterType="java.util.HashMap" statementType="CALLABLE">
126+
{call sptest.echoDate(
127+
#{input date,jdbcType=DATE,mode=IN},
128+
#{output date,jdbcType=DATE,mode=OUT}
129+
)}
130+
</select>
123131

124132
</mapper>

src/test/java/org/apache/ibatis/submitted/sptests/SPTest.java

+20
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.sql.Connection;
2525
import java.sql.DriverManager;
2626
import java.sql.SQLException;
27+
import java.util.Date;
2728
import java.util.HashMap;
2829
import java.util.List;
2930
import java.util.Map;
@@ -183,6 +184,25 @@ public void testAdderAsUpdate() {
183184
}
184185
}
185186

187+
// issue #145
188+
@Test
189+
public void testEchoDate() {
190+
SqlSession sqlSession = sqlSessionFactory.openSession();
191+
try {
192+
HashMap<String, Object> parameter = new HashMap<String, Object>();
193+
Date now = new Date();
194+
parameter.put("input date", now);
195+
196+
SPMapper spMapper = sqlSession.getMapper(SPMapper.class);
197+
spMapper.echoDate(parameter);
198+
199+
java.sql.Date outDate = new java.sql.Date(now.getTime());
200+
assertEquals(outDate.toString(), parameter.get("output date").toString());
201+
} finally {
202+
sqlSession.close();
203+
}
204+
}
205+
186206
/*
187207
* This test shows the use of a declared parameter map. We generally prefer
188208
* inline parameters, because the syntax is more intuitive (no pesky question

0 commit comments

Comments
 (0)