<insert id="insertPjCustomAttribute" parameterType="com.devops.server.model.PjCustomAttribute"> INSERT INTO
`PJ_CUSTOM_ATTRIBUTE`
(PJ_ID,NAME,VALUE,CREATE_TIME) VALUES <foreach collection="list" item="listRelation" separator=","> (#{listRelation.pjId},#{listRelation.name},#{listRelation.value},#{listRelation.createTime}) </foreach> </insert>
此sql語句,mapper.java中的參數為List<PjCustomAttribute> list,插入時,parameterType是PjCustomAttribute的全路徑。
在foreach中,collection是list,item是遍歷出來的每個PjCustomAttribute對象,在這兒我起的名字叫listRelation(可隨意起名),separator以逗號分隔
#{ }中是對象的屬性