package com.mybatis.mapper;

import com.mybatis.handle.ContentTypeHandler;
import com.mybatis.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface UserMapper {
    @Insert("INSERT INTO USERTEST(NAME,SEX,HOBBY) VALUES (#{name},#{sex}," +
            "#{hobby,typeHandler=com.mybatis.handle.ContentTypeHandler})")
    int insert(User user);


    @Insert({
            "<script>",
            "insert into USERTEST(name, sex, hobby) values ",
            "<foreach collection='list' item='item' separator=','>",
            "(#{item.name}, #{item.sex}, #{item.hobby,typeHandler=com.mybatis.handle.ContentTypeHandler})",
            "</foreach>",
            "</script>"
    })
    boolean batchInsert(@Param(value="list")List<User> list);
}
