Skip to content

Commit 8c83f86

Browse files
committedApr 12, 2021
完成MyBatis的Demo
1 parent e159880 commit 8c83f86

File tree

15 files changed

+1089
-431
lines changed

15 files changed

+1089
-431
lines changed
 

‎mybatis/mybatis_1/.idea/workspace.xml

+141-28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

‎mybatis/mybatis_2/.idea/workspace.xml

+94-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mybatis/mybatis_3/.idea/workspace.xml

+140-36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mybatis/mybatis_4/.idea/workspace.xml

+113-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mybatis/mybatis_5/.idea/workspace.xml

+103-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mybatis/mybatis_6/.idea/workspace.xml

+225-187
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mybatis/mybatis_7/.idea/workspace.xml

+149-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎mybatis/mybatis_7/src/main/java/mybatis_test/App.java

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public void test1(){
6666
logger.info("country pointer : {}, country2 pointer: {}",System.identityHashCode(country),System.identityHashCode(country2));
6767
logger.info("country name: {}, country2 name: {}",country.countryName,country2.countryName);
6868

69+
//这一步有查询数据库,因为selectById和selectById2是不同的方法
70+
Country country2_2 = countryMapper.selectById2(1L);
71+
72+
logger.info("country pointer : {}, country2_2 pointer: {}",System.identityHashCode(country),System.identityHashCode(country2_2));
73+
logger.info("country name: {}, country2_2 name: {}",country.countryName,country2_2.countryName);
74+
6975
//但是,在同一个事务里面,用其他方法就不会返回这个对象.
7076
//所以,一级缓存总是以方法和参数作为缓存的key
7177
showCountryList();

‎mybatis/mybatis_7/src/main/java/mybatis_test/mapper/CountryMapper.java

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
public interface CountryMapper {
1515
List<Country> selectAll();
1616
Country selectById(@Param("id")Long countryId);
17+
Country selectById2(@Param("id")Long countryId);
1718
int insertList(List<Country> countryList);
1819
}

‎mybatis/mybatis_7/src/main/resources/mapper/CountryMapper.xml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<select id="selectById" resultType="Country">
99
select id,countryName,countryCode,createTime,modifyTime from t_country where id = #{id};
1010
</select>
11+
<select id="selectById2" resultType="Country">
12+
select id,countryName,countryCode,createTime,modifyTime from t_country where id = #{id};
13+
</select>
1114
<insert id="insertList" useGeneratedKeys="true" keyProperty="id">
1215
insert into t_country(countryName,countryCode) VALUES
1316
<foreach collection="list" item="country" separator=",">

‎mybatis/mybatis_7/target/classes/mapper/CountryMapper.xml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<select id="selectById" resultType="Country">
99
select id,countryName,countryCode,createTime,modifyTime from t_country where id = #{id};
1010
</select>
11+
<select id="selectById2" resultType="Country">
12+
select id,countryName,countryCode,createTime,modifyTime from t_country where id = #{id};
13+
</select>
1114
<insert id="insertList" useGeneratedKeys="true" keyProperty="id">
1215
insert into t_country(countryName,countryCode) VALUES
1316
<foreach collection="list" item="country" separator=",">
Binary file not shown.
Binary file not shown.

‎mybatis/mybatis_8/.idea/workspace.xml

+111-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.