mybatis 标签记录

来源:互联网 发布:淘宝付款二维码在哪里 编辑:程序博客网 时间:2024/05/16 10:01
  1. mysql数据库(其他数据库就不知道了)插入一个对象时返回主键
    <insert id="addShareActivity" parameterType="com.luolai.ec.model.activity.ShareActivityVO"useGeneratedKeys="true" keyProperty="id"><![CDATA[insert into as_activity_share(user_id,user_name,level_name,create_date,content,image_path,good_count,is_check,integral,site_id,comment_count,activity_id,type) values(#{userId},#{userName},#{levelName},#{createDate},#{content},#{imagePath},#{goodCount},#{isCheck},#{integral},#{siteId},#{commentCount},#{activityId},#{type})]]></insert>
    useGeneratedKeys="true"    表示返回主键
    keyProperty="id"           表示返回的值为对象 id 字段

  1. foreach  使用<pre name="code" class="html"><!-- 审核后,批量修改留言的状态  --><pre name="code" class="html"><update id="updateSuperPeopleMessageStatus" parameterType="list">UPDATE sp_message SET is_check=1 WHERE id in<foreach item="messageId" index="index" collection="list" open="(" close=")" separator=",">#{messageId}</foreach></update>
  2. 设置 延迟加载<pre name="code" class="html"><configuration><settings>    <setting name="lazyLoadingEnabled" value="true"/></settings></configuration>

0 0
原创粉丝点击