Skip to content

Commit a39eefa

Browse files
authored
Update mybatisplus (apache#83)
* update mybatisplus * update mybatis-plus * uncomment parent * add licenses
1 parent e0dfd37 commit a39eefa

File tree

18 files changed

+814
-173
lines changed

18 files changed

+814
-173
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
# MybatisPlus-Generator Demo
22+
## Introduction
23+
24+
This demo shows how to use IoTDB-MybatisPlus-Generator
25+
26+
### Version usage
27+
28+
IoTDB: 2.0.1-beta
29+
mybatisPlus: 3.5.10
30+
31+
### 1. Install IoTDB
32+
33+
please refer to [https://iotdb.apache.org/#/Download](https://iotdb.apache.org/#/Download)
34+
35+
### 2. Startup IoTDB
36+
37+
please refer to [Quick Start](http://iotdb.apache.org/UserGuide/Master/Get%20Started/QuickStart.html)
38+
39+
Then we need to create a database 'test' by cli in table model
40+
```
41+
create database test;
42+
use test;
43+
```
44+
Then we need to create a database 'table'
45+
```sql
46+
CREATE TABLE mix (
47+
time TIMESTAMP TIME,
48+
region STRING TAG,
49+
plant_id STRING TAG,
50+
device_id STRING TAG,
51+
model_id STRING ATTRIBUTE,
52+
maintenance STRING ATTRIBUTE,
53+
temperature FLOAT FIELD,
54+
humidity FLOAT FIELD,
55+
status Boolean FIELD,
56+
arrival_time TIMESTAMP FIELD
57+
) WITH (TTL=31536000000);
58+
```
59+
60+
### 3. Build Dependencies with Maven in your Project
61+
62+
```
63+
<properties>
64+
<mybatisplus.version>3.5.10</mybatisplus.version>
65+
<maven.compiler.source>17</maven.compiler.source>
66+
<maven.compiler.target>17</maven.compiler.target>
67+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
68+
<spring-boot.version>3.4.5</spring-boot.version>
69+
<spring.version>6.2.6</spring.version>
70+
<iotdb-jdbc.version>2.0.4-SNAPSHOT</iotdb-jdbc.version>
71+
<io-springfox.version>3.0.0</io-springfox.version>
72+
</properties>
73+
74+
<dependencies>
75+
<dependency>
76+
<groupId>com.baomidou</groupId>
77+
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
78+
<version>${mybatisplus.version}</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>com.baomidou</groupId>
82+
<artifactId>mybatis-plus-generator</artifactId>
83+
<version>${mybatisplus.version}</version>
84+
</dependency>
85+
86+
<dependency>
87+
<groupId>org.apache.iotdb</groupId>
88+
<artifactId>iotdb-jdbc</artifactId>
89+
<version>${iotdb-jdbc.version}</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.springframework.boot</groupId>
93+
<artifactId>spring-boot-starter</artifactId>
94+
<version>${spring-boot.version}</version>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.springframework.boot</groupId>
98+
<artifactId>spring-boot-starter-web</artifactId>
99+
<version>${spring-boot.version}</version>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.springframework.boot</groupId>
103+
<artifactId>spring-boot-starter-test</artifactId>
104+
<version>${spring-boot.version}</version>
105+
<scope>test</scope>
106+
</dependency>
107+
108+
<dependency>
109+
<groupId>io.springfox</groupId>
110+
<artifactId>springfox-swagger2</artifactId>
111+
<version>${io-springfox.version}</version>
112+
</dependency>
113+
<dependency>
114+
<groupId>io.springfox</groupId>
115+
<artifactId>springfox-swagger-ui</artifactId>
116+
<version>${io-springfox.version}</version>
117+
</dependency>
118+
119+
<dependency>
120+
<groupId>org.projectlombok</groupId>
121+
<artifactId>lombok</artifactId>
122+
<version>1.18.36</version>
123+
</dependency>
124+
<dependency>
125+
<groupId>com.github.jeffreyning</groupId>
126+
<artifactId>mybatisplus-plus</artifactId>
127+
<version>1.7.5-RELEASE</version>
128+
</dependency>
129+
</dependencies>
130+
```
131+
132+
### 4. Start the Main.java
133+
134+
### 5. the target file location
135+
136+
You can see the target file in your Project
137+
```
138+
org/apache/iotdb/controller/MixController.java
139+
org/apache/iotdb/entity/Mix.java
140+
org/apache/iotdb/mapper/MixMapper.xml
141+
org/apache/iotdb/service/MixService.java
142+
org/apache/iotdb/service/MixServiceImpl.java
143+
org/apache/iotdb/MixMapper.xml
144+
145+
```
146+
147+
### 6. add & alter Annotations
148+
149+
The generated code files `entity/Table1.java` and `entity/Table2.java` need to be manually adjusted to support multi-primary key queries.
150+
151+
```java
152+
// add import
153+
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
154+
155+
// add @MppMultiId
156+
@MppMultiId
157+
// alter @TableId() -->> @TableField()
158+
@TableField("time")
159+
private Date time;
160+
161+
// add @MppMultiId
162+
@MppMultiId
163+
// alter @TableId() -->> @TableField()
164+
@TableField("region")
165+
private String region;
166+
167+
// add @MppMultiId
168+
@MppMultiId
169+
// alter @TableId() -->> @TableField()
170+
@TableField("plant_id")
171+
private String plantId;
172+
173+
// add @MppMultiId
174+
@MppMultiId
175+
// alter @TableId() -->> @TableField()
176+
@TableField("device_id")
177+
private String deviceId;
178+
//
179+
180+
```
181+

examples/mybatisplus-generator/pom.xml

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,31 @@
2121
-->
2222
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2323
<modelVersion>4.0.0</modelVersion>
24+
2425
<parent>
2526
<groupId>org.apache.iotdb</groupId>
2627
<artifactId>iotdb-extras-parent</artifactId>
2728
<version>2.0.4-SNAPSHOT</version>
2829
<relativePath>../../pom.xml</relativePath>
2930
</parent>
31+
3032
<groupId>org.apache.iotdb</groupId>
3133
<artifactId>mybatisplus-generator-example</artifactId>
3234
<name>IoTDB: Example: Mybatis Plus Generator</name>
3335
<version>2.0.4-SNAPHOT</version>
36+
3437
<properties>
3538
<mybatisplus.version>3.5.10</mybatisplus.version>
3639
<maven.compiler.source>17</maven.compiler.source>
3740
<maven.compiler.target>17</maven.compiler.target>
3841
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3942
<spring-boot.version>3.4.5</spring-boot.version>
4043
<spring.version>6.2.6</spring.version>
44+
<iotdb-jdbc.version>2.0.4-SNAPSHOT</iotdb-jdbc.version>
45+
<io-springfox.version>3.0.0</io-springfox.version>
4146
</properties>
47+
4248
<dependencies>
43-
<dependency>
44-
<groupId>org.mybatis</groupId>
45-
<artifactId>mybatis</artifactId>
46-
<version>3.5.19</version>
47-
</dependency>
4849
<dependency>
4950
<groupId>com.baomidou</groupId>
5051
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
@@ -53,17 +54,13 @@
5354
<dependency>
5455
<groupId>com.baomidou</groupId>
5556
<artifactId>mybatis-plus-generator</artifactId>
56-
<version>3.5.10</version>
57-
</dependency>
58-
<dependency>
59-
<groupId>org.apache.velocity</groupId>
60-
<artifactId>velocity-engine-core</artifactId>
61-
<version>2.4.1</version>
57+
<version>${mybatisplus.version}</version>
6258
</dependency>
59+
6360
<dependency>
6461
<groupId>org.apache.iotdb</groupId>
6562
<artifactId>iotdb-jdbc</artifactId>
66-
<version>${iotdb.version}</version>
63+
<version>${iotdb-jdbc.version}</version>
6764
</dependency>
6865
<dependency>
6966
<groupId>org.springframework.boot</groupId>
@@ -76,44 +73,55 @@
7673
<version>${spring-boot.version}</version>
7774
</dependency>
7875
<dependency>
79-
<groupId>org.springdoc</groupId>
80-
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
81-
<version>2.8.6</version>
76+
<groupId>org.springframework.boot</groupId>
77+
<artifactId>spring-boot-starter-test</artifactId>
78+
<version>${spring-boot.version}</version>
79+
<scope>test</scope>
80+
</dependency>
81+
82+
<dependency>
83+
<groupId>io.springfox</groupId>
84+
<artifactId>springfox-swagger2</artifactId>
85+
<version>${io-springfox.version}</version>
8286
</dependency>
87+
<dependency>
88+
<groupId>io.springfox</groupId>
89+
<artifactId>springfox-swagger-ui</artifactId>
90+
<version>${io-springfox.version}</version>
91+
</dependency>
92+
8393
<dependency>
8494
<groupId>org.projectlombok</groupId>
8595
<artifactId>lombok</artifactId>
8696
<version>1.18.36</version>
8797
</dependency>
98+
<dependency>
99+
<groupId>com.github.jeffreyning</groupId>
100+
<artifactId>mybatisplus-plus</artifactId>
101+
<version>1.7.5-RELEASE</version>
102+
</dependency>
88103
</dependencies>
104+
89105
<build>
90106
<plugins>
91107
<plugin>
92-
<groupId>org.apache.maven.plugins</groupId>
93-
<artifactId>maven-dependency-plugin</artifactId>
94-
<configuration>
95-
<ignoredDependencies>
96-
<!-- For some reason this plugin missed it being used for a constant import -->
97-
<ignoredDependency>org.apache.iotdb:isession</ignoredDependency>
98-
</ignoredDependencies>
99-
<usedDependencies>
100-
<!-- These are used at runtime in tests -->
101-
<usedDependency>com.baomidou:mybatis-plus-spring-boot3-starter</usedDependency>
102-
<usedDependency>org.apache.velocity:velocity-engine-core</usedDependency>
103-
<usedDependency>org.springframework.boot:spring-boot-starter</usedDependency>
104-
<usedDependency>org.springframework.boot:spring-boot-starter-web</usedDependency>
105-
<usedDependency>org.springdoc:springdoc-openapi-starter-webmvc-ui</usedDependency>
106-
<usedDependency>org.projectlombok:lombok</usedDependency>
107-
</usedDependencies>
108-
</configuration>
109-
</plugin>
110-
<plugin>
111-
<groupId>org.apache.maven.plugins</groupId>
112-
<artifactId>maven-deploy-plugin</artifactId>
108+
<groupId>org.mybatis.generator</groupId>
109+
<artifactId>mybatis-generator-maven-plugin</artifactId>
110+
<version>1.4.2</version>
111+
<dependencies>
112+
<dependency>
113+
<groupId>org.apache.iotdb</groupId>
114+
<artifactId>mybatis-generator-plugin</artifactId>
115+
<version>2.0.2-SNAPSHOT</version>
116+
</dependency>
117+
</dependencies>
113118
<configuration>
114-
<skip>true</skip>
119+
<verbose>true</verbose>
120+
<overwrite>true</overwrite>
121+
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
115122
</configuration>
116123
</plugin>
117124
</plugins>
118125
</build>
126+
119127
</project>

0 commit comments

Comments
 (0)