Passing multiple columns in myBatis

前端 未结 2 1901
后悔当初
后悔当初 2021-02-04 11:48

I want to know, how do we pass multiple columns in a myBatis association tag.

For example, I have the following xml snippet in one my mapper.xml file:

&l         


        
2条回答
  •  我在风中等你
    2021-02-04 12:48

    You should use the following syntax for composite keys:

    column="{prop1=col1,prop2=col2}".
    

    Where prop1, prop2 are parameters of the associated query and col1, col2 are sql columns passed to that query.

    In your case:

    CourseMapper.xml:

    column="{courseId=id,userId=user_id}" 
    ...
    select id, user_id, ... from course ...
    

    CourseSubscriptionMapper.xml:

    
    

    I just checked it worked fine for me. If you have any questions, please feel free to ask.

提交回复
热议问题