发表于: 2018-03-07 20:16:48

1 490


今日完成

1.上午又过了一遍项目的方案,问题还有很多。还是集中在限购,定时任务,回款,匹配这几个模块。

2.下午准备小课堂,讲了mybatis的常用标签和动态sql的使用

(1)常用的标签

 <!--1.根据id查找-->
  <select id="findStudentById" parameterType="Integer" resultType="lujing.pojo.Student">

   SELECT * FROM student WHERE id = #{id}
</select>

  <!--2.sql 标签与include标签 -->
  <sql id="sql_demo">name,school</sql>

  <select id="findStudentById2" parameterType="Integer" resultType="lujing.pojo.Student">

      SELECT
<include refid="sql_demo"/>
      FROM student WHERE id = #{id}
</select>

  <!--3. 模糊查询-->
  <select id="findStudentById3" parameterType="lujing.pojo.Student" resultType="lujing.pojo.Student">

      SELECT
*
      FROM student WHERE name LIKE "%"#{name}"%"
</select>

  <select id="findStudentById31" parameterType="lujing.pojo.Student" resultType="lujing.pojo.Student">
      SELECT
*
      FROM student WHERE name LIKE #{name}
</select>


  <!--4. if 标签-->
  <select id="findStudentById4" parameterType="lujing.pojo.Student" resultType="lujing.pojo.Student">

      SELECT
*
      FROM student WHERE name LIKE '%${name}%'

<if test="address != null and address !=''">
          AND address LIKE '%${address}%'
</if>

  </select>

  <!--bind 标签-->
  <select id="findStudentById5" parameterType="lujing.pojo.Student" resultType="lujing.pojo.Student">

      SELECT
*
      FROM student WHERE name LIKE '%${name}%'

<if test="address != null and address !=''">
          <bind name="pattern" value="'%'+address+'%'"/>
          AND address LIKE #{pattern}
</if>

  </select>
  <!--where 标签-->
  <select id="findStudentById6" parameterType="lujing.pojo.Student" resultType="lujing.pojo.Student">

      SELECT
*
      FROM student
<where>
          <if test="name !=null and name != ''">
              name LIKE '%${name}%'
</if>
          <if test="address != null and address !=''">

              AND address LIKE '%${address}%'
</if>
      </where>

  </select>
  <!--foreach -->
  <select id="findStudentById7" parameterType="lujing.pojo.Student" resultType="lujing.pojo.Student">

      SELECT
*
      FROM student
<where>

          <if test="ids != null and ids !=''">

              <foreach collection="ids" item="ids2" open="(" close=")" separator="or">
                  id = #{ids2}
</foreach>
          </if>
          <if test="name !=null and name != ''">
              AND name LIKE '%${name}%'
</if>
          <if test="address != null and address !=''">

              AND address LIKE '%${address}%'
</if>

      </where>
  </select>

  <!--set 标签-->
  <update id="updateStudentById" parameterType="lujing.pojo.Student">
      UPDATE student
<set>
          <if test="name !=null and name != ''">
              name = #{name},
</if>
          <if test="address != null and address !=''">

              address = #{address},
</if>
      </set>
      WHERE id = #{id}
</update>

2.学习了多线程中synchronized 关键字的使用------同步代码块

demo:

public class Ticket {


public static void main(String[] args) {
TicketRun ticketRun = new TicketRun();
       Thread a = new Thread(ticketRun);
       Thread b = new Thread(ticketRun);
       Thread c = new Thread(ticketRun);
       Thread d = new Thread(ticketRun);
       a.start();
       b.start();
       c.start();
       d.start();
   }
}

class TicketRun implements Runnable{
private int num =100 ;
   @Override
   public void run() {

while (true){

synchronized (this){
if(num > 0){
try {
Thread.sleep(20);
                   } catch (InterruptedException e) {
e.printStackTrace();
                   }
System.out.println(Thread.currentThread().getName() +"....."+ num--);
               }
}

}
}
}

同步可以用在火车上上厕所来形容,但一个人进入之后,其他人会看到一个有人/无人的标识,其他人就不能进入。

明日计划

1.把方案做完

遇到问题

1.几个难点的解决方案

收获

1.多线程的了解。

2.mybatis 常用标签的学习


返回列表 返回列表
评论

    分享到