闲杂小记(八)

来源:互联网 发布:网站排名云优化工具 编辑:程序博客网 时间:2024/04/29 23:01

1.增量写法:

Album getAlbum(@Param("aid") long aid, @Param("withDelete") boolean withDelete, @Param("lastTime") Date lastTime);

<select id="getAlbum" resultMap="BaseResultMap">    SELECT    <include refid="Base_Column_List"/>    <if test="lastTime==null">        ,a.is_deleted    </if>    FROM bp_album a    <where>        AND a.aid = #{aid,jdbcType=BIGINT}        <if test="lastTime != null">            AND a.update_time &gt;= #{lastTime, jdbcType=TIMESTAMP}        </if>        <if test="!withDelete">            AND a.is_deleted = FALSE        </if>    </where></select>

2. 当某个list不被引用时,可以手动将它设为null,以便垃圾回收,释放内存。

List<Picture> pictureList = pictureMapper.getMyList(userID,lastId,limit+1,lastDate);if(!CollectionUtils.isEmpty(pictureList)){    for(Picture picture:pictureList){        if(null==picture){            continue;        }        RecordDTO recordDTO = getPictureRecordDTO(picture);        dataList.add(recordDTO);    }    pictureList.clear();    pictureList=null;}

0 0
原创粉丝点击