MyBatis settings
Study notes:
Mybatis The setting information can be configured or not configured. After configuring the setting of Mybatis, it will affect its runtime behavior. The following are the keywords of related setting information and their meanings:
aggressiveLazyLoding: When enabled (true is also the default value), calls to any lazy attribute will be loaded with lazy loading Properties object is fully loaded.
If not enabled (false), each attribute will be loaded as needed.
autoMappingBehavior: Specify how Mybatis automatically maps to fields or attributes. It contains three values:
NONE: Cancel automatic mapping.
## PARTIAL (default value): Only result sets that do not define nested result set mappings will be mapped.
FULL: Automatically map any complex result set.
callSettersOnNulls: When the value in the specified result set is null, whether to call the mapping object color setter (not put when mapping the object) method, this is for Map.keySet() dependencies or null value initialization is useful when.
The default value is false
##Note: Basic types int and Boolean cannot be set to null.
cacheEnabled: Affects the cache global switch configured in all mappers. The default value is true.defaultExecutorType: Configure the default executor.
## SIMPLE: Simple executor
REUSE: The executor will reuse prepared statements (prepared, statements)
BATCH: The executor will reuse statements and perform batch updates.
defaultStatementTimeout: Set the supermarket time, which determines the corresponding number of seconds the driver waits for the database. When it is not set, the driver’s default waiting seconds are used.
The default value is Not Set(null)
##defaultScriptingLanguage: Specifies the default language generated by dynamic SQL. The default value is:
duct[\n] org.apche.ibatis.sc.ripting.xmltags.XMLDynamicLanguageDriver
You can customize the alias of the class or the fully qualified name of the class.
localCacheScope: Mybatis uses the local cache mechanism (Local Cache) to prevent circular references (circular references) and accelerate repeated nested queries.
The default value is SESSION Cache all queries executed in a session
STATEMENT Session is only used for statement execution, and different queries for the same SqlSession The call will not share data
jdbcTypeForNull: When no specific jdbc type is provided for the parameter, specify the JDBC type for the null value. Some drivers need to specify the JDBC type of the column. In most cases, just use the general type, such as NULL, VARCHAR, OTHER (default value)
##safeRowBoundsEnabled: Allowed to be used in nested statements Pagination (RowBounds).
The default value is false
mapUnderscoreToCamelCase: Whether to enable camel case naming rule (camel case) mapping, that is, from the classic database column name A_COLUMN to the classic Similar mapping of Java property aColumn.
The default value is false
useGeneratedKeys: Allows JDBC to automatically generate primary keys and requires driver compatibility. If set to true, it forces the use of automatically generated primary keys. Although some drivers are incompatible, they can still work normally.
The default value is false
multipleResultSetsEnabled: Whether to allow a single statement to return multiple result sets (requires compatible driver).
The default value is true.
The above is the detailed content of Mybatis related settings. For more information, please follow other related articles on the PHP Chinese website!