Tuesday, January 8, 2019
AWS Amplify
类似于Google Analytics分析,网站的点击数,时间等
Monday, January 7, 2019
Wednesday, January 2, 2019
AWS AppSync简介
用于手机,网站的实时data sync服务
MyBatis简介
SqlSessionFactory是单例模式
从SqlSessionFactory中获取SqlSession
SqlSession调用Mapper
public interface BlogMapper {
@Select("SELECT * FROM blog WHERE id = #{id}")
Blog selectBlog(int id);
}
BlogMapper mapper = session.getMapper(BlogMapper.class);
Blog blog = mapper.selectBlog(101);
将上述SQL语句写到XML中
resultType直接映射到自定义类,resultMap是哈希表,手动映射
<select id="selectUsers" resultType="User">
select id, username, password
from users
where id = #{id}
</select>
<select id="selectUsers" resultMap="userResultMap">
select user_id, user_name, hashed_password
from some_table
where id = #{id}
</select>
<resultMap id="userResultMap" type="User">
<id property="id" column="user_id" />
<result property="username" column="user_name"/>
<result property="password" column="hashed_password"/>
</resultMap>
动态SQL的if, choose, when, otherwise, trim, where, set, foreach, bind语句
java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite
BlogMapper m
自动生成文件有4个包括:
Student.java: table对应的java object
StudentMapper.xml用于mybatis生成java的指导文件
StudentMapper.java: 对表格增删减除的操作
StudentExample.java: 用于产生对每个column的大于等于小于条件判断
updateByExample, updateByEampleSelective区别
Example的意思是where条件,所以updateByExample(User, UserExample)是按where条件更新Object的全部字段,若为空,直接更新。
updateByEampleSelective(User, UserExample)是按where条件更新Object的某些字段(不为null),所以null的话,myBatis就不会更新。所以如果选用Selective的API,就不能将该字段更新为null,因为null是一个保留字来决定是否更新该字段。
updateByPrimaryKey(User)按主键更新,主键设在User中,这里就不用指定where条件。updateByExampleSelective按主键更新非null字段。
MyBatis简介
MyBatis Generator
updateByExample介绍
从SqlSessionFactory中获取SqlSession
SqlSession调用Mapper
public interface BlogMapper {
@Select("SELECT * FROM blog WHERE id = #{id}")
Blog selectBlog(int id);
}
BlogMapper mapper = session.getMapper(BlogMapper.class);
Blog blog = mapper.selectBlog(101);
resultType直接映射到自定义类,resultMap是哈希表,手动映射
<select id="selectUsers" resultType="User">
select id, username, password
from users
where id = #{id}
</select>
<select id="selectUsers" resultMap="userResultMap">
select user_id, user_name, hashed_password
from some_table
where id = #{id}
</select>
<resultMap id="userResultMap" type="User">
<id property="id" column="user_id" />
<result property="username" column="user_name"/>
<result property="password" column="hashed_password"/>
</resultMap>
动态SQL的if, choose, when, otherwise, trim, where, set, foreach, bind语句
java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite
BlogMapper m
自动生成文件有4个包括:
Student.java: table对应的java object
StudentMapper.xml用于mybatis生成java的指导文件
StudentMapper.java: 对表格增删减除的操作
StudentExample.java: 用于产生对每个column的大于等于小于条件判断
updateByExample, updateByEampleSelective区别
Example的意思是where条件,所以updateByExample(User, UserExample)是按where条件更新Object的全部字段,若为空,直接更新。
updateByEampleSelective(User, UserExample)是按where条件更新Object的某些字段(不为null),所以null的话,myBatis就不会更新。所以如果选用Selective的API,就不能将该字段更新为null,因为null是一个保留字来决定是否更新该字段。
updateByPrimaryKey(User)按主键更新,主键设在User中,这里就不用指定where条件。updateByExampleSelective按主键更新非null字段。
MyBatis简介
MyBatis Generator
updateByExample介绍
Sunday, December 30, 2018
Java目录
Java 8
Stream API, Optional API, 跟CompletableFuture
lang3
EqualsBuilder
ToStringBuilder
Google Guava (Google Collections Library)
ImmutableSet.of
ImmutableMap.of
Java的Null pointer exception
Java中的ThreadLocal和弱引用
ORM:
lombok
Database ORM:
MyBatis
JSON:
fasterxml
Build tool:
Gradle简介
Saturday, December 15, 2018
NTLK
NTLK主要用于比较两文档的相似度
https://my.oschina.net/Samyan/blog/1796944
https://my.oschina.net/Samyan/blog/1796944
Tuesday, November 6, 2018
Cucumber简介
Cucumber是平实语言版的unit test,可用于包层次的测试。优势在于它允许非程序员参与,需求更加明确。
测试方法:
https://www.cnblogs.com/TankXiao/archive/2012/02/20/2347016.html
BDD/Functional test framwork: Cucumber
TDD:
https://cucumber.io/
Gherkin
plain text语音来描述unit test中的arrange(mock), act, assert。
例子
Scenario: Breaker guesses a word
Given the Maker has chosen a word
When the Breaker makes a guess
Then the Maker is asked to score
测试方法:
https://www.cnblogs.com/TankXiao/archive/2012/02/20/2347016.html
BDD/Functional test framwork: Cucumber
TDD:
https://cucumber.io/
Gherkin
plain text语音来描述unit test中的arrange(mock), act, assert。
例子
Scenario: Breaker guesses a word
Given the Maker has chosen a word
When the Breaker makes a guess
Then the Maker is asked to score
Subscribe to:
Posts (Atom)