Skip to content

Commit 8623a5c

Browse files
2b3c5112b3c511CritasWang
authored
add default param (#77)
* add default param * Update readme.md --------- Co-authored-by: 2b3c511 <rong.li@timecho.com> Co-authored-by: CritasWang <critas@outlook.com>
1 parent 0d1a499 commit 8623a5c

3 files changed

Lines changed: 68 additions & 3 deletions

File tree

examples/mybatis-generator/readme.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use test;
4545
```
4646
Then we need to create a database 'table'
4747
```
48-
CREATE TABLE mix3 (
48+
CREATE TABLE mix (
4949
time TIMESTAMP TIME,
5050
region STRING TAG,
5151
plant_id STRING TAG,
@@ -87,7 +87,13 @@ CREATE TABLE mix3 (
8787

8888
### 5. put The generatorConfig.xml in your project
8989

90-
The location of the ` configurationFile ` configuration ` generatorConfig.xml ` file can be found in the ` src/main/resources ` template of this project for reference` Copy its content and place it in the corresponding location
90+
- `src/main/resources/generatorConfig.xml`
91+
92+
each table generates an entity object
93+
94+
- `src/main/resources/generatorConfigByExample.xml`
95+
96+
The generated object will contain many "by Example" methods. If you do not want to generate these, you can configure to cancel them in the subsequent table elements
9197

9298
### 6. exec 'mvn mybatis-generator:generate'
9399

@@ -99,6 +105,7 @@ You can see the target file in your Project
99105

100106
```
101107
org/apache/iotdb/mybatis/plugin/model/Mix.java
108+
org/apache/iotdb/mybatis/plugin/model/MixExample.java
102109
org/apache/iotdb/mybatis/plugin/mapper/MixMapper.java
103110
org/apache/iotdb/mybatis/plugin/xml/MixMapper.xml
104111
```

examples/mybatis-generator/src/main/resources/generatorConfig.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<javaClientGenerator type="XMLMAPPER" targetPackage="org.apache.iotdb.mybatis.plugin.mapper" targetProject="src/main/java">
5252
<!-- <property name="enableSubPackages" value="true"/>-->
5353
</javaClientGenerator>
54-
<table schema="test" tableName="mix" domainObjectName="Mix" enableSelectByPrimaryKey="true" enableInsert="true" enableDeleteByPrimaryKey="true">
54+
<table schema="test" tableName="mix" domainObjectName="Mix" enableSelectByPrimaryKey="true" enableInsert="true" enableDeleteByPrimaryKey="true" enableUpdateByPrimaryKey="false">
5555
<property name="virtualKeyColumns" value="time,device_id,device_name,device_tag"/>
5656
</table>
5757
</context>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
2+
3+
<!--
4+
5+
Licensed to the Apache Software Foundation (ASF) under one or more
6+
7+
contributor license agreements. See the NOTICE file distributed with
8+
this work for additional information regarding copyright ownership.
9+
The ASF licenses this file to You under the Apache License, Version 2.0
10+
11+
(the "License"); you may not use this file except in compliance with
12+
13+
the License. You may obtain a copy of the License at
14+
http://www.apache.org/licenses/LICENSE-2.0
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
19+
-->
20+
<generatorConfiguration>
21+
<classPathEntry location="/apache/iotdb/iotdb-client/jdbc/target/iotdb-jdbc-2.0.2-SNAPSHOT-jar-with-dependencies.jar"/>
22+
<!-- mvn mybatis-generator:generate hierarchical/flat-->
23+
<context id="mybatis3" targetRuntime="Mybatis3" defaultModelType="flat">
24+
<!-- <property name="suppressAllComments" value="true"/>-->
25+
<!-- <property name="useActualColumnNames" value="false"/>-->
26+
<!-- <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>-->
27+
<!-- <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>-->
28+
<plugin type="org.apache.iotdb.mybatis.plugin.LombokPlugin"/>
29+
<plugin type="org.apache.iotdb.mybatis.plugin.BatchInsertPlugin"/>
30+
<!-- <plugin type="org.apache.iotdb.mybatis.plugin.SerializablePlugin"/>-->
31+
<plugin type="org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin"/>
32+
<!-- <commentGenerator type="generator.org.apache.iotdb.mybatis.plugin.CNCommentGenerator">-->
33+
<!-- <property name="suppressAllComments" value="true"/>-->
34+
<!-- </commentGenerator>-->
35+
<commentGenerator type="org.apache.iotdb.mybatis.plugin.generator.SwaggerCommentGenerator">
36+
<property name="suppressAllComments" value="true"/>
37+
<property name="suppressDate" value="true"/>
38+
<property name="addRemarkComments" value="true"/>
39+
</commentGenerator>
40+
<jdbcConnection driverClass="org.apache.iotdb.jdbc.IoTDBDriver" connectionURL="jdbc:iotdb://127.0.0.1:6667/test?sql_dialect=table" userId="root" password="root"/>
41+
<javaTypeResolver type="org.apache.iotdb.mybatis.plugin.generator.resolver.IoTDBJavaTypeResolver">
42+
<property name="forceBigDecimals" value="false"/>
43+
</javaTypeResolver>
44+
<javaModelGenerator targetPackage="org.apache.iotdb.mybatis.plugin.model" targetProject="src/main/java">
45+
<!-- <property name="enableSubPackages" value="true"/>-->
46+
<property name="trimStrings" value="true"/>
47+
</javaModelGenerator>
48+
<sqlMapGenerator targetPackage="org.apache.iotdb.mybatis.plugin.xml" targetProject="src/main/java">
49+
<!-- <property name="enableSubPackages" value="true"/>-->
50+
</sqlMapGenerator>
51+
<javaClientGenerator type="XMLMAPPER" targetPackage="org.apache.iotdb.mybatis.plugin.mapper" targetProject="src/main/java">
52+
<!-- <property name="enableSubPackages" value="true"/>-->
53+
</javaClientGenerator>
54+
<table schema="test" tableName="mix" domainObjectName="Mix" enableSelectByPrimaryKey="true" enableInsert="true" enableDeleteByPrimaryKey="true" enableUpdateByPrimaryKey="false" enableSelectByExample="true">
55+
<property name="virtualKeyColumns" value="time,device_id,device_name,device_tag"/>
56+
</table>
57+
</context>
58+
</generatorConfiguration>

0 commit comments

Comments
 (0)