My favorites | Sign in
Project Home Downloads Issues Source
Checkout   Browse   Changes  
Changes to /sub-projects/generator/trunk/core/mybatis-generator-core/src/site/xhtml/configreference/javaClientGenerator.xhtml
r5351 vs. r5433 Compare: vs.  Format:
Revision r5433
Go to: 
/sub-projects/generator/trunk/core/mybatis-generator-core/src/site/xhtml/configreference/javaClientGenerator.xhtml   r5351 /sub-projects/generator/trunk/core/mybatis-generator-core/src/site/xhtml/configreference/javaClientGenerator.xhtml   r5433
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head> 5 <head>
6 <title>The &lt;javaClientGenerator&gt; Element</title> 6 <title>The &lt;javaClientGenerator&gt; Element</title>
7 <link rel="stylesheet" type="text/css" href="../mbgstyle.css" /> 7 <link rel="stylesheet" type="text/css" href="../mbgstyle.css" />
8 </head> 8 </head>
9 <body> 9 <body>
10 <h1>The &lt;javaClientGenerator&gt; Element</h1> 10 <h1>The &lt;javaClientGenerator&gt; Element</h1>
11 <p>The &lt;javaClientGenerator&gt; element is used to define properties of the Java 11 <p>The &lt;javaClientGenerator&gt; element is used to define properties of the Java
12 client generator. The Java client Generator builds Java interfaces and classes that allow 12 client generator. The Java client Generator builds Java interfaces and classes that allow
13 easy use of the generated Java model and XML map files. For iBATIS2 target environments, these 13 easy use of the generated Java model and XML map files. For iBATIS2 target environments, these
14 generated objects take the form of DAO interface and implementation classes. For MyBatis, the 14 generated objects take the form of DAO interface and implementation classes. For MyBatis, the
15 generated objects take the form of mapper interfaces. 15 generated objects take the form of mapper interfaces.
16 This element is a optional child element 16 This element is a optional child element
17 of the <a href="context.html">&lt;context&gt;</a> element. If you do not 17 of the <a href="context.html">&lt;context&gt;</a> element. If you do not
18 specify this element, then MyBatis Generator (MBG) will not generate Java client interfaces and classes.</p> 18 specify this element, then MyBatis Generator (MBG) will not generate Java client interfaces and classes.</p>
19 <h2>Required Attributes</h2> 19 <h2>Required Attributes</h2>
20 <table border="1" cellspacing="0" cellpadding="5"> 20 <table border="1" cellspacing="0" cellpadding="5">
21 <tr> 21 <tr>
22 <th>Attribute</th> 22 <th>Attribute</th>
23 <th>Description</th> 23 <th>Description</th>
24 </tr> 24 </tr>
25 <tr> 25 <tr>
26 <td valign="top">type</td> 26 <td valign="top">type</td>
27 <td>This attribute is used to select one of the predefined Java Client generators, or 27 <td>This attribute is used to select one of the predefined Java Client generators, or
28 to specify a user provided Java Client generator. 28 to specify a user provided Java Client generator.
29 Any user provided DAO generator must extend the class 29 Any user provided DAO generator must extend the class
30 <code>org.mybatis.generator.codegen.AbstractJavaClientGenerator</code> 30 <code>org.mybatis.generator.codegen.AbstractJavaClientGenerator</code>
31 class, and must have a public default constructor. 31 class, and must have a public default constructor.
32 <p>The attribute accepts the following values for selecting one of the 32 <p>The attribute accepts the following values for selecting one of the
33 predefined generators:</p> 33 predefined generators:</p>
34 <table cellpadding="5"> 34 <table cellpadding="5">
35 <tr> 35 <tr>
36 <td colspan="2">If the &lt;context&gt; targetRuntime is <b>MyBatis3</b>:</td> 36 <td colspan="2">If the &lt;context&gt; targetRuntime is <b>MyBatis3</b>:</td>
37 </tr> 37 </tr>
38 <tr> 38 <tr>
39 <th nowrap="nowrap" valign="top">ANNOTATEDMAPPER</th> 39 <th nowrap="nowrap" valign="top">ANNOTATEDMAPPER</th>
40 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper 40 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper
41 infrastructure. The interfaces will be based on annotations and MyBatis 3.x SqlProviders. 41 infrastructure. The interfaces will be based on annotations and MyBatis 3.x SqlProviders.
42 No XML mapper files will be generated. 42 No XML mapper files will be generated.
43 <p>The ANNOTATEDMAPPER requires MyBatis version 3.0.4 or higher.</p> 43 <p>The ANNOTATEDMAPPER requires MyBatis version 3.0.4 or higher.</p>
44 </td> 44 </td>
45 </tr> 45 </tr>
46 <tr> 46 <tr>
47 <th nowrap="nowrap" valign="top">MIXEDMAPPER</th> 47 <th nowrap="nowrap" valign="top">MIXEDMAPPER</th>
48 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper 48 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper
49 infrastructure. The interfaces will be based on a mix of annotations and XML. 49 infrastructure. The interfaces will be based on a mix of annotations and XML.
50 An annotation will be used where a simple annotation will work. This client 50 An annotation will be used where a simple annotation will work. This client
51 will not generate and Sql Provider, so all complex dynamic SQL will be generated 51 will not generate and Sql Provider, so all complex dynamic SQL will be generated
52 in XML. 52 in XML.
53 <p>The MIXEDMAPPER requires MyBatis version 3.0.4 or higher.</p> 53 <p>The MIXEDMAPPER requires MyBatis version 3.0.4 or higher.</p>
54 </td> 54 </td>
55 </tr> 55 </tr>
56 <tr> 56 <tr>
57 <th nowrap="nowrap" valign="top">XMLMAPPER</th> 57 <th nowrap="nowrap" valign="top">XMLMAPPER</th>
58 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper 58 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper
59 infrastructure. The interfaces will be dependent on generated XML mapper files.</td> 59 infrastructure. The interfaces will be dependent on generated XML mapper files.</td>
60 </tr> 60 </tr>
61 <tr> 61 <tr>
62 <td colspan="2">If the &lt;context&gt; targetRuntime is <b>MyBatis3Simple</b>:</td> 62 <td colspan="2">If the &lt;context&gt; targetRuntime is <b>MyBatis3Simple</b>:</td>
63 </tr> 63 </tr>
64 <tr> 64 <tr>
65 <th nowrap="nowrap" valign="top">ANNOTATEDMAPPER</th> 65 <th nowrap="nowrap" valign="top">ANNOTATEDMAPPER</th>
66 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper 66 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper
67 infrastructure. The interfaces will be based on annotations and MyBatis 3.x SqlProviders. 67 infrastructure. The interfaces will be based on annotations and MyBatis 3.x SqlProviders.
68 No XML mapper files will be generated. 68 No XML mapper files will be generated.
69 <p>The ANNOTATEDMAPPER requires MyBatis version 3.0.4 or higher.</p> 69 <p>The ANNOTATEDMAPPER requires MyBatis version 3.0.4 or higher.</p>
70 </td> 70 </td>
71 </tr> 71 </tr>
72 <tr> 72 <tr>
73 <th nowrap="nowrap" valign="top">XMLMAPPER</th> 73 <th nowrap="nowrap" valign="top">XMLMAPPER</th>
74 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper 74 <td>The generated objects will be Java interfaces for the MyBatis 3.x mapper
75 infrastructure. The interfaces will be dependent on generated XML mapper files.</td> 75 infrastructure. The interfaces will be dependent on generated XML mapper files.</td>
76 </tr> 76 </tr>
77 <tr> 77 <tr>
78 <td colspan="2">If the &lt;context&gt; targetRuntime is <b>Ibatis2Java2</b> 78 <td colspan="2">If the &lt;context&gt; targetRuntime is <b>Ibatis2Java2</b>
79 or <b>Ibatis2Java5</b>:</td> 79 or <b>Ibatis2Java5</b>:</td>
80 </tr> 80 </tr>
81 <tr> 81 <tr>
82 <th nowrap="nowrap" valign="top">IBATIS</th> 82 <th nowrap="nowrap" valign="top">IBATIS</th>
83 <td>The generated objects will conform to the (deprecated) iBATIS DAO framework.</td> 83 <td>The generated objects will conform to the (deprecated) iBATIS DAO framework.</td>
84 </tr> 84 </tr>
85 <tr> 85 <tr>
86 <th nowrap="nowrap" valign="top">GENERIC-CI</th> 86 <th nowrap="nowrap" valign="top">GENERIC-CI</th>
87 <td>The generated objects will rely only on the SqlMapClient. The SqlMapClient 87 <td>The generated objects will rely only on the SqlMapClient. The SqlMapClient
88 will be supplied by constructor dependency injection. 88 will be supplied by constructor dependency injection.
89 The generated objects will be in the form of DAO interfaces amd implementation classes. 89 The generated objects will be in the form of DAO interfaces amd implementation classes.
90 </td> 90 </td>
91 </tr> 91 </tr>
92 <tr> 92 <tr>
93 <th nowrap="nowrap" valign="top">GENERIC-SI</th> 93 <th nowrap="nowrap" valign="top">GENERIC-SI</th>
94 <td>The generated objects will rely only on the SqlMapClient. The SqlMapClient 94 <td>The generated objects will rely only on the SqlMapClient. The SqlMapClient
95 will be supplied by setter dependency injection. 95 will be supplied by setter dependency injection.
96 The generated objects will be in the form of DAO interfaces amd implementation classes. 96 The generated objects will be in the form of DAO interfaces amd implementation classes.
97 </td> 97 </td>
98 </tr> 98 </tr>
99 <tr> 99 <tr>
100 <th nowrap="nowrap" valign="top">SPRING</th> 100 <th nowrap="nowrap" valign="top">SPRING</th>
101 <td>The generated objects will conform to the Spring DAO framework.</td> 101 <td>The generated objects will conform to the Spring DAO framework.</td>
102 </tr> 102 </tr>
103 </table> 103 </table>
104 </td> 104 </td>
105 </tr> 105 </tr>
106 <tr> 106 <tr>
107 <td valign="top">targetPackage</td> 107 <td valign="top">targetPackage</td>
108 <td>This is the package where the generated interfaces and implementation classes 108 <td>This is the package where the generated interfaces and implementation classes
109 will be placed. In 109 will be placed. In
110 the default generators, the property "enableSubPackages" 110 the default generators, the property "enableSubPackages"
111 controls how the actual package is calculated. If true, 111 controls how the actual package is calculated. If true,
112 then the calculated package will be the targetPackage plus 112 then the calculated package will be the targetPackage plus
113 sub packages for the table's catalog and schema if they exist. 113 sub packages for the table's catalog and schema if they exist.
114 If "enableSubPackages" is false (the default) then the calculated package will be 114 If "enableSubPackages" is false (the default) then the calculated package will be
115 exactly what is specified in the targetPackage attribute. 115 exactly what is specified in the targetPackage attribute.
116 MBG will create folders as required for the generated 116 MBG will create folders as required for the generated
117 packages. 117 packages.
118 <p><b>Note:</b> the package for implementation classes may 118 <p><b>Note:</b> the package for implementation classes may
119 be overridden by specifying the optional <code>implementationPackage</code> 119 be overridden by specifying the optional <code>implementationPackage</code>
120 attribute as shown below.</p></td> 120 attribute as shown below.</p></td>
121 </tr> 121 </tr>
122 <tr> 122 <tr>
123 <td valign="top">targetProject</td> 123 <td valign="top">targetProject</td>
124 <td>This is used to specify a target project for the 124 <td>This is used to specify a target project for the
125 generated interfaces and classes. When running in the Eclipse 125 generated interfaces and classes. When running in the Eclipse
126 environment, this specifies the project and source folder where 126 environment, this specifies the project and source folder where
127 the objects will be saved. 127 the objects will be saved.
128 In other environments, this value should be an existing directory 128 In other environments, this value should be an existing directory
129 on the local file system. MBG will not create this directory if 129 on the local file system. MBG will not create this directory if
130 it does not exist.</td> 130 it does not exist.</td>
131 </tr> 131 </tr>
132 </table> 132 </table>
133 133
134 <h2>Optional Attributes</h2> 134 <h2>Optional Attributes</h2>
135 <table border="1" cellspacing="0" cellpadding="5"> 135 <table border="1" cellspacing="0" cellpadding="5">
136 <tr> 136 <tr>
137 <th>Attribute</th> 137 <th>Attribute</th>
138 <th>Description</th> 138 <th>Description</th>
139 </tr> 139 </tr>
140 <tr> 140 <tr>
141 <td valign="top">implementationPackage</td> 141 <td valign="top">implementationPackage</td>
142 <td>If specified, implementation classes will be placed in this package. 142 <td>If specified, implementation classes will be placed in this package.
143 In the default generators, the property "enableSubPackages" 143 In the default generators, the property "enableSubPackages"
144 controls how the actual package is calculated. If true, 144 controls how the actual package is calculated. If true,
145 then the calculated package will be the implementationPackage plus 145 then the calculated package will be the implementationPackage plus
146 sub packages for the table's catalog and schema if they exist. 146 sub packages for the table's catalog and schema if they exist.
147 If "enableSubPackages" is false (the default) then the calculated package will be 147 If "enableSubPackages" is false (the default) then the calculated package will be
148 exactly what is specified in the implementationPackage attribute. 148 exactly what is specified in the implementationPackage attribute.
149 MBG will create folders as required for the generated 149 MBG will create folders as required for the generated
150 packages.</td> 150 packages.</td>
151 </tr> 151 </tr>
152 </table> 152 </table>
153 153
154 <h2>Child Elements</h2> 154 <h2>Child Elements</h2>
155 <ul> 155 <ul>
156 <li><a href="property.html">&lt;property&gt;</a> (0..N)</li> 156 <li><a href="property.html">&lt;property&gt;</a> (0..N)</li>
157 </ul> 157 </ul>
158 158
159 <h2>Supported Properties</h2> 159 <h2>Supported Properties</h2>
160 <p>This table lists the properties of the default SQL Map generators that can be 160 <p>This table lists the properties of the default SQL Map generators that can be
161 specified with the <a href="property.html">&lt;property&gt;</a> child element:</p> 161 specified with the <a href="property.html">&lt;property&gt;</a> child element:</p>
162 <table border="1" cellspacing="0" cellpadding="5"> 162 <table border="1" cellspacing="0" cellpadding="5">
163 <tr> 163 <tr>
164 <th>Property Name</th> 164 <th>Property Name</th>
165 <th>Property Values</th> 165 <th>Property Values</th>
166 </tr> 166 </tr>
167 <tr> 167 <tr>
168 <td valign="top">enableSubPackages</td> 168 <td valign="top">enableSubPackages</td>
169 <td>This property is used to select whether MBG will generate different 169 <td>This property is used to select whether MBG will generate different
170 Java packages for the objects based on the catalog and schema of the 170 Java packages for the objects based on the catalog and schema of the
171 introspected table. 171 introspected table.
172 <p>For example, suppose a table MYTABLE in schema MYSCHMA. 172 <p>For example, suppose a table MYTABLE in schema MYSCHMA.
173 Also suppose that the targetPackage attribute is set to "com.mycompany". 173 Also suppose that the targetPackage attribute is set to "com.mycompany".
174 If this property is true, the generated DAO interface and class for the table 174 If this property is true, the generated DAO interface and class for the table
175 will be placed in 175 will be placed in
176 the package "com.mycompany.myschema". If the property is false, the generated 176 the package "com.mycompany.myschema". If the property is false, the generated
177 SQL Map will be placed in the "com.mycompany" schema.</p> 177 SQL Map will be placed in the "com.mycompany" schema.</p>
178 <p><i>The default value is false.</i></p></td> 178 <p><i>The default value is false.</i></p></td>
179 </tr> 179 </tr>
180 <tr> 180 <tr>
181 <td valign="top">exampleMethodVisibility</td> 181 <td valign="top">exampleMethodVisibility</td>
182 <td>This property is used to set the visibility of the different "ByExample" 182 <td>This property is used to set the visibility of the different "ByExample"
183 methods - selectByExample, deleteByExample, etc. If not specified, the 183 methods - selectByExample, deleteByExample, etc. If not specified, the
184 methods will be public and will be declared in the interface. 184 methods will be public and will be declared in the interface.
185 This property allows you to hide these methods if you only want to use them 185 This property allows you to hide these methods if you only want to use them
186 to implement other specialized methods. 186 to implement other specialized methods.
187 <table cellpadding="5"> 187 <table cellpadding="5">
188 <tr> 188 <tr>
189 <th nowrap="nowrap" valign="top">public</th> 189 <th nowrap="nowrap" valign="top">public</th>
190 <td><i>This is the default value</i><br/> 190 <td><i>This is the default value</i><br/>
191 The generated methods in the implementation class will be public, 191 The generated methods in the implementation class will be public,
192 and the methods will be declared in the interface.</td> 192 and the methods will be declared in the interface.</td>
193 </tr> 193 </tr>
194 <tr> 194 <tr>
195 <th nowrap="nowrap" valign="top">private</th> 195 <th nowrap="nowrap" valign="top">private</th>
196 <td>The generated methods in the implementation class will be private, 196 <td>The generated methods in the implementation class will be private,
197 and the methods will not be declared in the interface 197 and the methods will not be declared in the interface
198 </td> 198 </td>
199 </tr> 199 </tr>
200 <tr> 200 <tr>
201 <th nowrap="nowrap" valign="top">protected</th> 201 <th nowrap="nowrap" valign="top">protected</th>
202 <td>The generated methods in the implementation class will be protected, 202 <td>The generated methods in the implementation class will be protected,
203 and the methods will not be declared in the interface 203 and the methods will not be declared in the interface
204 </td> 204 </td>
205 </tr> 205 </tr>
206 <tr> 206 <tr>
207 <th nowrap="nowrap" valign="top">default</th> 207 <th nowrap="nowrap" valign="top">default</th>
208 <td>The generated methods in the implementation class will have default 208 <td>The generated methods in the implementation class will have default
209 (package) visibility, 209 (package) visibility,
210 and the methods will not be declared in the interface 210 and the methods will not be declared in the interface
211 </td> 211 </td>
212 </tr> 212 </tr>
213 </table> 213 </table>
214 <p><b>Important note:</b> this property is ignored if the target runtime is 214 <p><b>Important note:</b> this property is ignored if the target runtime is
215 MyBatis3.</p> 215 MyBatis3.</p>
216 </td> 216 </td>
217 </tr> 217 </tr>
218 <tr> 218 <tr>
219 <td valign="top">methodNameCalculator</td> 219 <td valign="top">methodNameCalculator</td>
220 <td>This property is used to select a method name calculator. A method name 220 <td>This property is used to select a method name calculator. A method name
221 calculator can be used to provide different names for the DAO methods. 221 calculator can be used to provide different names for the DAO methods.
222 You can select one of the predefined values, or you can specify the 222 You can select one of the predefined values, or you can specify the
223 fully qualified name of a class that implements the 223 fully qualified name of a class that implements the
224 <code>org.mybatis.generator.api.DAOMethodNameCalculator</code> interface 224 <code>org.mybatis.generator.api.DAOMethodNameCalculator</code> interface
225 if neither of the supplied options are appropriate in your environment. 225 if neither of the supplied options are appropriate in your environment.
226 <table cellpadding="5"> 226 <table cellpadding="5">
227 <tr> 227 <tr>
228 <th nowrap="nowrap" valign="top">default</th> 228 <th nowrap="nowrap" valign="top">default</th>
229 <td><i>This is the default value</i><br/> 229 <td><i>This is the default value</i><br/>
230 The generated methods names will be very simple ("insert", 230 The generated methods names will be very simple ("insert",
231 "updateByPrimaryKey", etc.)</td> 231 "updateByPrimaryKey", etc.)</td>
232 </tr> 232 </tr>
233 <tr> 233 <tr>
234 <th nowrap="nowrap" valign="top">extended</th> 234 <th nowrap="nowrap" valign="top">extended</th>
235 <td>The generated method names will include the name of the domain object 235 <td>The generated method names will include the name of the domain object
236 associated with the method ("insertWidget", "updateWidgetByPrimaryKey", etc.) 236 associated with the method ("insertWidget", "updateWidgetByPrimaryKey", etc.)
237 </td> 237 </td>
238 </tr> 238 </tr>
239 </table> 239 </table>
240 <p><b>Important note:</b> this property is ignored if the target runtime is 240 <p><b>Important note:</b> this property is ignored if the target runtime is
241 MyBatis3.</p> 241 MyBatis3.</p>
242 </td> 242 </td>
243 </tr> 243 </tr>
244 <tr> 244 <tr>
245 <td valign="top">rootInterface</td> 245 <td valign="top">rootInterface</td>
246 <td>This property can be used to specify a super interface for all generated 246 <td>This property can be used to specify a super interface for all generated
247 interface objects. This value may be overridden by specifying 247 interface objects. This value may be overridden by specifying
248 the <code>rootInterface</code> property on a Table configuration. 248 the <code>rootInterface</code> property on a Table configuration.
249 <p><b>Important:</b> MBG does not verify that the interface exists, or is a 249 <p><b>Important:</b> MBG does not verify that the interface exists, or is a
250 valid Java interface.</p> 250 valid Java interface.</p>
251 <p>If specified, the value of this property should be a fully qualified 251 <p>If specified, the value of this property should be a fully qualified
252 interface name (like com.mycompany.MyRootInterface).</p></td> 252 interface name (like com.mycompany.MyRootInterface).</p></td>
253 </tr> 253 </tr>
254 <tr>
255 <td valign="top">useLegacyBuilder</td>
256 <td>If true, then annotated clients will use the SqlBuilder from MyBatis to generate
257 dynamic SQL. With MyBatis 3.2 and later, that builder was deprecated in favor of
258 the new SQL class. If false, MBG will generate clients that use the new SQL builder.
259 <p><i>The default value is false.</i></p></td>
260 </tr>
254 </table> 261 </table>
255 262
256 <h2>Example</h2> 263 <h2>Example</h2>
257 <p>This element specifies that we always want to place generated interfaces and 264 <p>This element specifies that we always want to place generated interfaces and
258 objects 265 objects
259 in the "'test.model" package and that we want to use subpackages based on the 266 in the "'test.model" package and that we want to use subpackages based on the
260 table schema and catalog. It also specifies that we want to generate 267 table schema and catalog. It also specifies that we want to generate
261 mapper interfaces that reference an XML configuration file for MyBatis3.</p> 268 mapper interfaces that reference an XML configuration file for MyBatis3.</p>
262 <pre> 269 <pre>
263 &lt;javaClientGenerator targetPackage="test.model" 270 &lt;javaClientGenerator targetPackage="test.model"
264 targetProject="\MyProject\src" type="XMLMAPPER"&gt; 271 targetProject="\MyProject\src" type="XMLMAPPER"&gt;
265 &lt;property name="enableSubPackages" value="true" /&gt; 272 &lt;property name="enableSubPackages" value="true" /&gt;
266 &lt;/javaClientGenerator&gt; 273 &lt;/javaClientGenerator&gt;
267 </pre> 274 </pre>
268 275
269 </body> 276 </body>
270 </html> 277 </html>
Powered by Google Project Hosting