mybatis 標籤記錄

  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>

    
    
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章