Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass multiple parameters and use them?

Hi I'm new to myBatis.

I'm using MyBatis and Spring with mybatis-spring.

How can I pass two different types of objects as parameters, and how can I use their properties in query?

<update id="update" parameterType="A, B"> <!-- @@? -->
  UPDATE SOME WHERE x=A.x AND y=B.y <!-- @@? -->
</update>
like image 225
Jin Kwon Avatar asked Jul 26 '14 06:07

Jin Kwon


1 Answers

Do not specify parameterType but use @Param annotation on parameters in mapper:

@Mapper
public interface MyMapper {

    void update(@Param("a") A a, @Param("b") B b);

    ...
}

Then reference them in mapping:

<update id="update" > 
   UPDATE SOME WHERE x=#{a.x} AND y=#{b.y}
</update>
like image 63
Roman Konoval Avatar answered Sep 30 '22 16:09

Roman Konoval