I will write a memorandum of MyBatis.
<if test="(author != null and author.name != '') or authorList.size() > 0">
</if>
column in
<foreach item="sample" open="(" close=")" collection="sampleList" separator=",">
#{sample}
</foreach>
<![CDATA[
column <= #{parameter}
]]>
column = #{parameter,jdbcType=DATE}
include
<sql id="sample">
column = True
<sql>
<select id="xxxxx" resultType="string">
select column from table where <include refid="sample" />
</select>
resultType
If the result is a List, resultType specifies the type of the contents of the List.
If you want to get it as List \
Bulk Insert
<insert id="xxxxx" parameterType="java.util.List">
insert into table(column,・ ・ ・) values
<foreach collection="list" item="item" separator=",">
( #{item.propertyName}, #{item.propertyName},・ ・ ・)
</foreach>
</insert>
Bulk Update
<update id="xxxxx" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";">
update table set column = #{item.propertyName} where column = #{item.propertyName}
</foreach>
</update>
jdbcType
jdbcType | java |
---|---|
VARCHAR | String |
INTEGER | int |
NUMERIC | BigDecimal |
BIT | boolean |
DATE | Date |
TIMESTAMP | Date |
"java.lang.String" can be written as "string". http://www.mybatis.org/mybatis-3/ja/configuration.html#typeAliases
void select(
@Param("param1") String param1,
@Param("param2") List<String> param2);
For Mapper XML, write parameterType = "map".
TableExample example = new TableExample();
example.createCriteria()
.andColumnEqualTo(value)
.andColumnEqualTo(value);
example.setOrderByClause("column DESC, column ASC");
Recommended Posts