The <javaTypeResolver> Element
The <javaTypeResolver> element is used to define properties of the Java Type Resolver. The Java Type Resolver is used to calculate Java types from database column information. The default Java Type Resolver attempts to make JDBC DECIMAL and NUMERIC types easier to use by substituting Integral types if possible (Long, Integer, Short, etc.) If this behavior is undesirable, set the property "forceBigDecimals" to "true". You can also substitute your own implementation if you want different behavior than the default. This element is an optional child element of the <context> element.
Note: if you use the MyBatis3Kotlin runtime, then the generator will automatically convert Java types to their appropriate Kotlin equivalents when applicable.
Required Attributes
None
Optional Attributes
Attribute | Description |
---|---|
type | This can be used to specify a user provided Java Type Resolver.
The class must implement the interface
org.mybatis.generator.api.JavaTypeResolver ,
and must have a public default constructor. The attribute also accepts
the special value DEFAULT in which case the default implementation will
be used (this has the same effect as not specifying the type). |
Child Elements
- <property> (0..N)
Supported Properties
This table lists the properties of the default Java type resolver that can be specified with the <property> child element:
Property Name | Property Values | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
forceBigDecimals |
This property is used to specify whether MyBatis Generator should force the use
of java.math.BigDecimal for DECIMAL and NUMERIC fields,
rather than substituting integral types when possible.
The property supports these values:
|
||||||||||||||
useJSR310Types |
This property is used to specify whether MyBatis Generator should force the use
of JSR-310 data types for DATE, TIME, and TIMESTAMP fields, rather than using java.util.Date .
If true, the types will be resolved as follows:
Note: the type resolver will always resolve the following JSR-310 types regardless of the value of this property:
|
Example
This element specifies that we always want to use the java.math.BigDecimal type for DECIMAL and NUMERIC columns:
<javaTypeResolver> <property name="forceBigDecimals" value="true" /> </javaTypeResolver>