J'écrirai un mémorandum de My Batis.
<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
Si le résultat est une liste, resultType spécifie le type du contenu de la liste.
Si vous voulez l'obtenir en tant que type 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" peut être écrit comme "string". http://www.mybatis.org/mybatis-3/ja/configuration.html#typeAliases
void select(
@Param("param1") String param1,
@Param("param2") List<String> param2);
Pour Mapper XML, écrivez parameterType = "map".
TableExample example = new TableExample();
example.createCriteria()
.andColumnEqualTo(value)
.andColumnEqualTo(value);
example.setOrderByClause("column DESC, column ASC");
Recommended Posts