zoukankan      html  css  js  c++  java
  • Spring 笔记

     1、级联查询 字段 关联的字段 使用的方法

    <association property="extendedAttributeCate" column="EXTENDED_ATTRIBUTE_CATE_ID"  select="com.aixuexi.diy.mapper.ExtendedAttributeCateMapper.selectByPrimaryKey"/>

    2、sql代码块

    <sql id="sql_page">
    <if test="id != null" >
    and ID=#{id,jdbcType=INTEGER}
    </if>
    <if test="lessonId != null" >
    and LESSON_ID=#{lessonId,jdbcType=INTEGER}
    </if>
    <if test="version != null" >
    and VERSION =#{version,jdbcType=VARCHAR}
    </if>
    <if test="extendedAttributeCateId != null" >
    and EXTENDED_ATTRIBUTE_CATE_ID =#{extendedAttributeCateId,jdbcType=INTEGER}
    </if>
    <if test="extendedAttributeId != null" >
    and EXTENDED_ATTRIBUTE_ID =#{extendedAttributeId,jdbcType=INTEGER}
    </if>
    <if test="createTime != null" >
    and CREATE_TIME = #{createTime,jdbcType=TIMESTAMP}
    </if>
    <if test="lastUpdateTime != null" >
    and LAST_UPDATE_TIME=#{lastUpdateTime,jdbcType=TIMESTAMP}
    </if>
    <if test="start!= null" >
    <if test="size!= null" >
    limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
    </if>
    </if>
    </sql>

     例如:

    <select id="CountByParamMap" resultType="java.lang.Integer" parameterType="java.util.Map" >
    select
    count(*)
    from LESSON_EXTENDED_ATTRIBUTE
    where 1=1
    <include refid="sql_page" />
    </select>

    使用 <include refid="sql_page" />

    3、单元测试

    @RunWith(SpringJUnit4ClassRunner.class) // 整合
    @ContextConfiguration(locations="classpath:spring-bean-*.xml") // 加载配置
    public class KnowledgeServiceImplTest {
    @Resource
    private KnowledgeService knowledgeService;

    @Test
    public void testList(){
    List<Knowledge> ks = knowledgeService.getBySubjectProduct(22);
    assertNotNull(ks);
    }

    @Test
    public void testGetByParent(){

    List<Knowledge> ks= knowledgeService.getByParent(3);
    assertNotNull(ks);
    }

    @Test
    public void testgetById(){
    Knowledge knowledge=knowledgeService.getById(3);
    assertNotNull(knowledge);
    }
    }

  • 相关阅读:
    Navicat连接mysql出现10061/10060错误的解决
    对话守则
    一次Django admin bug解决的思维过程
    Think different
    SVN版本库的迁移
    Windows Phone 8 锁屏背景与通知
    Windows Phone 7 应用升级 Windows phone 8 方案预览 选择合适的 Key Feature
    从 windows phone7 到 windows phone 8 更新 如何设配两个版本
    windows phone 8 语音 Speech for Windows Phone 8
    windows phone 8 中的应用间通信
  • 原文地址:https://www.cnblogs.com/qianyukun/p/5125238.html
Copyright © 2011-2022 走看看