package org.zln.dao;
import org.springframework.stereotype.Repository;
import org.zln.domain.Message;
import java.util.List;
/**
* Created by sherry on 000006/7/6 19:16.
*/
@Repository
public class MessageDao extends BaseDao {
public List queryMessageList(String command,String description){
return sqlSessionTemplate.selectList("org.zln.domain.Message.queryMessageList");
}
}
-- 测试用表
create table User (
id identity
,username varchar(100)
,password varchar(100)
);
test-data.sql
insert into User (username,password) values ('姓名1','pd1');
insert into User (username,password) values ('姓名2','pd2');
insert into User (username,password) values ('姓名3','pd3');
insert into User (username,password) values ('姓名4','pd4');
insert into User (username,password) values ('姓名5','pd5');
insert into User (username,password) values ('姓名6','pd6');
insert into User (username,password) values ('姓名7','pd7');
insert into User (username,password) values ('姓名8','pd8');
insert into User (username,password) values ('姓名9','pd9');
insert into User (username,password) values ('姓名10','pd10');
insert into User (username,password) values ('姓名11','pd11');
数据源配置
package org.zln.spb.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import javax.sql.DataSource;
/**
* 数据库相关配置
* Created by nbcoolkid on 2017-06-26.
*/
@Configuration
public class DbConfig {
/**
* H2嵌入式数据库,用于开发
* @return
*/
@Bean(destroyMethod = "shutdown")
@Primary
@Profile("dev")
public DataSource dataSourceH2(){
return new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.addScript("classpath:sql/schema.sql")
.addScript("classpath:sql/test-data.sql")
.setScriptEncoding("UTF-8")
.build();
}
}
Dao
UserMapper
package org.zln.spb.dao.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.zln.spb.pojo.vo.User;
/**
* Created by nbcoolkid on 2017-06-26.
*/
@Mapper
public interface UserMapper {
User selectByPrimaryKey(int id);
}
UserMapper.xml
测试
package org.zln.spb.dao.mapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
/**
* Created by nbcoolkid on 2017-06-26.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
public class UserMapperTest {
@Autowired
private UserMapper userMapper;
@Test
public void selectByPrimaryKey() throws Exception {
System.out.println("UserMapper:"+userMapper);
System.out.println(userMapper.selectByPrimaryKey(1));
}
}
MyBatis配置文件详解
Mybatis映射文件详解
动态SQL元素
if
and role_name like concat('%',#{roleName},'%')
choose、when、otherwise
and role_no=#{roleNo}
and role_name like concat('%',#{roleName},'%')
and note is not null
Tomcat的组成部分 1、server
A Server element represents the entire Catalina servlet container. (Singleton) 2、service
service包括多个connector以及一个engine,其职责为处理由connector获得的客户请求。
3、connector
一个connector
基本概念: 1.OOP中唯一关系的是对象的接口是什么,就像计算机的销售商她不管电源内部结构是怎样的,他只关系能否给你提供电就行了,也就是只要知道can or not而不是how and why.所有的程序是由一定的属性和行为对象组成的,不同的对象的访问通过函数调用来完成,对象间所有的交流都是通过方法调用,通过对封装对象数据,很大限度上提高复用率。 2.OOP中最重要的思想是类,类是模板是蓝图,
由于明天举要上课,所以刚刚将代码敲了一遍PL/SQL的函数和包体的实现(单例模式过几天好好的总结下再发出来);以便明天能更好的学习PL/SQL的循环,今天太累了,所以早点睡觉,明天继续PL/SQL总有一天我会将你永远的记载在心里,,,
函数;
函数:PL/SQL中的函数相当于java中的方法;函数有返回值
定义函数的
--输入姓名找到该姓名的年薪
create or re
/*
*编写控制结构
*/
--条件分支语句
--简单条件判断
DECLARE
v_sal NUMBER(6,2);
BEGIN
select sal into v_sal from emp
where lower(ename)=lower('&name');
if v_sal<2000 then
update emp set
public class CollectionDemo implements Serializable,Comparable<CollectionDemo>{
private static final long serialVersionUID = -2958090810811192128L;
private int id;
private String nam