From 7b70f282c1235b5c07f530ac3928d2b2e5606668 Mon Sep 17 00:00:00 2001
From: Weaxs <459312872@qq.com>
Date: Fri, 12 Jan 2024 01:33:35 +0800
Subject: [PATCH 1/2] update dev-java-mybatis
---
...v-guide-sample-application-java-mybatis.md | 66 +++++++++++++------
1 file changed, 45 insertions(+), 21 deletions(-)
diff --git a/develop/dev-guide-sample-application-java-mybatis.md b/develop/dev-guide-sample-application-java-mybatis.md
index ea97e1250344..b43ca7349127 100644
--- a/develop/dev-guide-sample-application-java-mybatis.md
+++ b/develop/dev-guide-sample-application-java-mybatis.md
@@ -77,7 +77,7 @@ cd tidb-java-mybatis-quickstart
6. 复制并粘贴对应连接字符串至 `env.sh` 中。需更改部分示例结果如下:
```shell
- export TIDB_HOST='{host}' # e.g. gateway01.ap-northeast-1.prod.aws.tidbcloud.com
+ export TIDB_HOST='{host}' # e.g. xxxxxx.aws.tidbcloud.com
export TIDB_PORT='4000'
export TIDB_USER='{user}' # e.g. xxxxxx.root
export TIDB_PASSWORD='{password}'
@@ -112,9 +112,9 @@ cd tidb-java-mybatis-quickstart
5. 复制并粘贴对应的连接字符串至 `env.sh` 中。需更改部分示例结果如下:
```shell
- export TIDB_HOST='{host}' # e.g. tidb.xxxx.clusters.tidb-cloud.com
+ export TIDB_HOST='{host}' # e.g. xxxxxx.aws.tidbcloud.com
export TIDB_PORT='4000'
- export TIDB_USER='{user}' # e.g. root
+ export TIDB_USER='{user}' # e.g. xxxxxx.root
export TIDB_PASSWORD='{password}'
export TIDB_DB_NAME='test'
export USE_SSL='false'
@@ -137,9 +137,9 @@ cd tidb-java-mybatis-quickstart
2. 复制并粘贴对应 TiDB 的连接字符串至 `env.sh` 中。需更改部分示例结果如下:
```shell
- export TIDB_HOST='{host}'
+ export TIDB_HOST='{host}' # e.g. xxxxxx.aws.tidbcloud.com
export TIDB_PORT='4000'
- export TIDB_USER='root'
+ export TIDB_USER='root' # e.g. xxxxxx.root
export TIDB_PASSWORD='{password}'
export TIDB_DB_NAME='test'
export USE_SSL='false'
@@ -193,19 +193,19 @@ cd tidb-java-mybatis-quickstart
-
-
-
+
+
+
-
+
```
-请将 `${tidb_jdbc_url}`、`${tidb_user}`、`${tidb_password}` 等替换为你的 TiDB 集群的实际值。并替换 `${mapper_location}` 的值为你的 mapper XML 配置文件的位置。如果你有多个 mapper XML 配置文件,需要添加多个 `` 标签。随后编写以下函数:
+请将 `${TIDB_JDBC_URL}`、`${TIDB_USER}`、`${TIDB_PASSWORD}` 等替换为你的 TiDB 集群的实际值。并替换 `${MAPPER_LOCATION}` 的值为你的 mapper XML 配置文件的位置。如果你有多个 mapper XML 配置文件,需要添加多个 `` 标签。随后编写以下函数:
```java
public SqlSessionFactory getSessionFactory() {
@@ -223,12 +223,18 @@ public SqlSessionFactory getSessionFactory() {
- insert into player (id, coins, goods)
- values (#{id,jdbcType=VARCHAR}, #{coins,jdbcType=INTEGER}, #{goods,jdbcType=INTEGER})
+ INSERT INTO player (id, coins, goods)
+ VALUES (#{id, jdbcType=VARCHAR}, #{coins, jdbcType=INTEGER}, #{goods, jdbcType=INTEGER})
```
+```java
+public interface PlayerMapper {
+ int insert(Player row);
+}
+```
+
更多信息参考[插入数据](/develop/dev-guide-insert-data.md)。
### 查询数据
@@ -248,13 +254,19 @@ public SqlSessionFactory getSessionFactory() {
```
+```java
+public interface PlayerMapper {
+ Player selectByPrimaryKey(String id);
+}
+```
+
更多信息参考[查询数据](/develop/dev-guide-get-data-from-single-table.md)。
### 更新数据
@@ -266,14 +278,20 @@ public SqlSessionFactory getSessionFactory() {
- update player
- set coins = #{coins,jdbcType=INTEGER},
- goods = #{goods,jdbcType=INTEGER}
- where id = #{id,jdbcType=VARCHAR}
+ UPDATE player
+ SET coins = #{coins, jdbcType=INTEGER},
+ goods = #{goods, jdbcType=INTEGER}
+ WHERE id = #{id, jdbcType=VARCHAR}
```
+```java
+public interface PlayerMapper {
+ int updateByPrimaryKey(Player row);
+}
+```
+
更多信息参考[更新数据](/develop/dev-guide-update-data.md)。
### 删除数据
@@ -285,12 +303,18 @@ public SqlSessionFactory getSessionFactory() {
- delete from player
- where id = #{id,jdbcType=VARCHAR}
+ DELETE FROM player
+ WHERE id = #{id, jdbcType=VARCHAR}
```
+```java
+public interface PlayerMapper {
+ int deleteByPrimaryKey(String id);
+}
+```
+
更多信息参考[删除数据](/develop/dev-guide-delete-data.md)。
## 下一步
From 708afebfa79b62e4a07111a11c21e5de13171ff7 Mon Sep 17 00:00:00 2001
From: Weaxs <459312872@qq.com>
Date: Mon, 15 Jan 2024 17:46:15 +0800
Subject: [PATCH 2/2] del interface PlayerMapper
---
...v-guide-sample-application-java-mybatis.md | 24 -------------------
1 file changed, 24 deletions(-)
diff --git a/develop/dev-guide-sample-application-java-mybatis.md b/develop/dev-guide-sample-application-java-mybatis.md
index b43ca7349127..f4835e94e8da 100644
--- a/develop/dev-guide-sample-application-java-mybatis.md
+++ b/develop/dev-guide-sample-application-java-mybatis.md
@@ -229,12 +229,6 @@ public SqlSessionFactory getSessionFactory() {
```
-```java
-public interface PlayerMapper {
- int insert(Player row);
-}
-```
-
更多信息参考[插入数据](/develop/dev-guide-insert-data.md)。
### 查询数据
@@ -261,12 +255,6 @@ public interface PlayerMapper {
```
-```java
-public interface PlayerMapper {
- Player selectByPrimaryKey(String id);
-}
-```
-
更多信息参考[查询数据](/develop/dev-guide-get-data-from-single-table.md)。
### 更新数据
@@ -286,12 +274,6 @@ public interface PlayerMapper {
```
-```java
-public interface PlayerMapper {
- int updateByPrimaryKey(Player row);
-}
-```
-
更多信息参考[更新数据](/develop/dev-guide-update-data.md)。
### 删除数据
@@ -309,12 +291,6 @@ public interface PlayerMapper {
```
-```java
-public interface PlayerMapper {
- int deleteByPrimaryKey(String id);
-}
-```
-
更多信息参考[删除数据](/develop/dev-guide-delete-data.md)。
## 下一步