Skip to content

Commit b50f3f4

Browse files
committed
updating documentation
1 parent be1b6a5 commit b50f3f4

File tree

1 file changed

+57
-28
lines changed

1 file changed

+57
-28
lines changed

README.md

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,20 @@ MyBatis Generator Plugins
99
Set of plugins for the mybatis-generator to further tweak the generated code.
1010

1111

12-
## AddClassAnnotationsPlugin
13-
14-
Plugin that will add the specified annotation to every generated class. There are 2 mandatory parameters to set:
15-
- **annotationClass**: The class of the annotation, this will be added as an import statement.
16-
- **annotationString**: The literal string that will be added, complete will all values
17-
18-
If you need to add multiple annotations, configure this plugin many times, one per annotation to add.
19-
20-
e.g.:
21-
```xml
22-
<plugin type="com.github.dcendents.mybatis.generator.plugin.annotation.AddClassAnnotationsPlugin">
23-
<property name="annotationClass" value="lombok.ToString" />
24-
<property name="annotationString" value="@ToString(callSuper = true)" />
25-
</plugin>
26-
<plugin type="com.github.dcendents.mybatis.generator.plugin.annotation.AddClassAnnotationsPlugin">
27-
<property name="annotationClass" value="lombok.EqualsAndHashCode" />
28-
<property name="annotationString" value="@EqualsAndHashCode(callSuper = true)" />
29-
</plugin>
30-
```
31-
3212
## CreateSubPackagePlugin
3313

3414
Powerful plugin that will rename the generated model, mappers and examples by moving them in a sub-package and/or append a suffix. This is intended to keep generated code apart from the final classes to allow the geneator plugin to overwrite them every time.
3515

3616
e.g.: some.package.Actor will now be generated as some.package.sub.ActorSuffix and will be abstract.
3717
some.package.ActorMapper will now be generated as some.package.sub.ActorMapperSuffix but methods will still expect and object of type some.package.Actor (to be created manually).
3818

39-
- **modelSubPackage**: The sub package to create for model classes.
40-
- **modelClassSuffix**: The suffix to add to model classes.
41-
- **mapperSubPackage**: The sub package to create for mapper interfaces.
42-
- **mapperClassSuffix**: The suffix to add to mapper interfaces.
43-
- **exampleSubPackage**: The sub package to create for example classes.
44-
- **exampleClassSuffix**: The suffix to add to example classes.
19+
There are 6 optional parameters to set:
20+
- *modelSubPackage*: The sub package to create for model classes.
21+
- *modelClassSuffix*: The suffix to add to model classes.
22+
- *mapperSubPackage*: The sub package to create for mapper interfaces.
23+
- *mapperClassSuffix*: The suffix to add to mapper interfaces.
24+
- *exampleSubPackage*: The sub package to create for example classes.
25+
- *exampleClassSuffix*: The suffix to add to example classes.
4526

4627
e.g.:
4728
```xml
@@ -56,8 +37,7 @@ e.g.:
5637

5738
## RenameExampleClassAndMethodsPlugin
5839

59-
Plugin that will rename the example classes and parameters to give them a more suitable name for a production environment. Also this plugin will fix the update statements and remove the id column(s).
60-
40+
Plugin that will rename the example classes and parameters to give them a more suitable name for a production environment. Also this plugin will fix the update statements and remove the id column(s). There are 4 mandatory parameters to set:
6141
- **classMethodSearchString**: The string to search in class names.
6242
- **classMethodReplaceString**: The replace value.
6343
- **parameterSearchString**: The string to search for parameter names.
@@ -73,6 +53,55 @@ e.g.:
7353
</plugin>
7454
```
7555

56+
## AddClassAnnotationsPlugin
57+
58+
Plugin that will add the specified annotation to every generated class. There are 2 mandatory parameters to set:
59+
- **annotationClass**: The class of the annotation, this will be added as an import statement.
60+
- **annotationString**: The literal string that will be added, complete will all values
61+
62+
If you need to add multiple annotations, configure this plugin many times, one per annotation to add.
63+
64+
e.g.:
65+
```xml
66+
<plugin type="com.github.dcendents.mybatis.generator.plugin.annotation.AddClassAnnotationsPlugin">
67+
<property name="annotationClass" value="lombok.ToString" />
68+
<property name="annotationString" value="@ToString(callSuper = true)" />
69+
</plugin>
70+
<plugin type="com.github.dcendents.mybatis.generator.plugin.annotation.AddClassAnnotationsPlugin">
71+
<property name="annotationClass" value="lombok.EqualsAndHashCode" />
72+
<property name="annotationString" value="@EqualsAndHashCode(callSuper = true)" />
73+
</plugin>
74+
```
75+
76+
## WrapObjectPlugin
77+
78+
Plugin that can be used to make a generated class wrap another java bean. For each property to wrap, the field will not be generated and the getter/setter will simply redirect to the wrapped java bean methods instead. This strategy can be used when you need to persist some third party objects but still want the flexibility to add new properties (like a database id). This pattern is more flexible than trying to extend the class. There are 2 mandatory and 3 optional parameters to set:
79+
- **fullyQualifiedTableName**: The name of the database table including the schema.
80+
- **objectClass**: The class of the object to be wrapped.
81+
- *objectFieldName*: The name of the field to add, will default to the class name starting with a lower case.
82+
- *includes*: A coma separated list of fields to delegate to the wrapped object, everything else will be excluded. If left blank all fields are included.
83+
- *excludes*: A coma separated list of fields to exclude.
84+
85+
The plugin need to be added for each table as needed.
86+
87+
e.g.:
88+
```xml
89+
<plugin type="com.github.dcendents.mybatis.generator.plugin.wrap.WrapObjectPlugin">
90+
<property name="fullyQualifiedTableName" value="public.film" />
91+
<property name="objectClass" value="com.github.dcendents.mybatis.jaxws.api.Film" />
92+
<property name="excludes" value="language" />
93+
</plugin>
94+
<plugin type="com.github.dcendents.mybatis.generator.plugin.wrap.WrapObjectPlugin">
95+
<property name="fullyQualifiedTableName" value="public.actor" />
96+
<property name="objectClass" value="com.github.dcendents.mybatis.jaxws.api.Actor" />
97+
</plugin>
98+
```
99+
100+
Demo
101+
====================
102+
103+
See the following project for a demo of all these plugins: https://github.com/dcendents/mybatis-jaxws
104+
76105
Build Metrics
77106
====================
78107

0 commit comments

Comments
 (0)