mybatis separator=
时间: 2023-10-08 16:05:28 浏览: 102
MyBatis separator is a feature that allows you to specify a custom string to be used as a separator between the elements of a collection when generating SQL statements. It is commonly used when you want to generate dynamic SQL queries with a variable number of parameters.
By default, MyBatis uses a comma (",") as the separator. However, you can override this default behavior by setting the `separator` attribute in MyBatis configuration or inline in your SQL statements.
Here is an example of how to use the `separator` attribute in MyBatis configuration:
```xml
<settings>
<setting name="jdbcTypeForNull" value="NULL" />
<setting name="mapUnderscoreToCamelCase" value="true" />
<setting name="logImpl" value="STDOUT_LOGGING" />
<setting name="localCacheScope" value="SESSION" />
<setting name="defaultExecutorType" value="SIMPLE" />
<setting name="callSettersOnNulls" value="true" />
<setting name="cacheEnabled" value="true" />
<!-- Set custom separator -->
<setting name="defaultStatementTimeout" value="25000" />
<setting name="defaultFetchSize" value="100" />
<setting name="safeRowBoundsEnabled" value="false" />
<setting name="mapUnderscoreToCamelCase" value="false" />
<setting name="separator" value="AND" />
</settings>
```
With this configuration, when generating SQL statements with MyBatis, the separator between elements in a collection will be "AND".
阅读全文