Hello, I'm a spring beginner!
I am using mybatis for STS.
Is there any way to put the collection right away using an annotation?
What I want to do is to transfer the following query from the mapper using @Insert to the method as a factor!
INSERT INTO tbname(v1, v2) VALUES (v1 in the first row of the collection, v2 in the first row of the collection), (...), (Last v1, Last v2);
Is there any way to deal with this?
spring mybatis
public interface HashcodeMapper {
@Insert({
"<script>",
"INSERT INTO tbname (v1, v2) VALUES ",
"<foreach collection='list' item='listItem' separator=','>",
"(#{listItem.v1}, #{listItem.v2})",
"</foreach>",
"</script>"
})
int insertList(@Param("list") List<Object> list);
}
© 2024 OneMinuteCode. All rights reserved.