I am trying to pass in startSequenceId
, stopSequenceId
, orderNumber
into the SQL map, however, i don't wish to use a typed object, i.e. parameterType="com.abc.Order"
, can i do so?
<select id="getSequenceIdByOrderNumber" parameterType="?" resultType="int">
select *
from log
where seq_id
between #{startSequenceId} and #{stopSequenceId}
and order_no = #{orderNumber}
and rownum = 1
</select>
You can use the built in parameterType 'map' eg
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("name", "abc");
parms.put("phone", "123");
parms.put("email", "[email protected]");
List<Contact> list = myBatis.selectList("getContacts",parms);
<!-- in xml mapper -->
<select id="getContacts" parameterType="map" resultMap="Contact">
SELECT * FROM CONTACT
WHERE CONTACT_NAME = ${name}
AND CONTACT_PHONE = ${phone}
AND CONTACT_MAIl = ${email}
</select>
@Chin I'll post what I had typed anyway with a simple example though you found what your looking for. My example using iBatis 2.3.4
<select id="retrieveTestXXX" parameterClass="java.util.Map" resultClass="java.lang.Integer">
SELECT
example_table.id
FROM example_table
WHERE example_table.xx_id = #testId# AND example_table.xx_id = #test2Id#
</select>
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With