1. 程式人生 > 其它 >openlayers 根據縮放層級給點要素新增聚合

openlayers 根據縮放層級給點要素新增聚合

set標籤用於更新語句,當同事要更新多個欄位時,我們需要留意當前是否是最後一個set,避免在後面出現,符號,使用set標籤後可自動去除最後的逗號

mapper:

<update id="updateProductTest" parameterType="products"> update products <set> <if test="pname != null and pname != ''"> pname = #{pname}, </if> <if test="price != null and price > 0"> price = #{price}, </if> <if test="pdate != null"> pdate = #{pdate}, </if> <if test="cid != null and cid != ''"> cid = #{cid}, </if> </set> where pid = #{pid} </update>

測試程式碼:

@Test public void updateTest2(){ SqlSession session = factory.openSession(); ProductsMapper mapper = session.getMapper(ProductsMapper.class); //獲取已有物件 Products product = mapper.selectProductById(7); product.setPname("雲南小土豆"); product.setPrice(10.5f); //執行更新 mapper.updateProductTest(product); System.out.println(product); session.commit(); session.close(); }