page, Integer state);
```
--------------------------------
### TenantLineHandler Interface Definition
Source: https://mybatis.plus/guide/interceptor-tenant-line.html
Defines the contract for handling tenant-specific logic, including retrieving tenant IDs, specifying tenant columns, and ignoring specific tables.
```java
public interface TenantLineHandler {
/**
* 获取租户 ID 值表达式,只支持单个 ID 值
*
*
* @return 租户 ID 值表达式
*/
Expression getTenantId();
/**
* 获取租户字段名
*
* 默认字段名叫: tenant_id
*
* @return 租户字段名
*/
default String getTenantIdColumn() {
return "tenant_id";
}
/**
* 根据表名判断是否忽略拼接多租户条件
*
* 默认都要进行解析并拼接多租户条件
*
* @param tableName 表名
* @return 是否忽略, true:表示忽略,false:需要解析并拼接多租户条件
*/
default boolean ignoreTable(String tableName) {
return false;
}
}
```
--------------------------------
### Spring MVC Configuration for MybatisPlusInterceptor
Source: https://mybatis.plus/guide/interceptor.html
Configure MybatisPlusInterceptor with PaginationInnerInterceptor in a Spring MVC application using XML beans.
```xml
```
--------------------------------
### MyBatis Configuration - Auto Mapping Behavior
Source: https://mybatis.plus/config
Defines MyBatis's automatic mapping strategy for data table fields to object properties. Options are NONE (no auto-mapping), PARTIAL (auto-mapping for non-nested results), and FULL (auto-mapping for all results).
```properties
autoMappingBehavior=PARTIAL
```
--------------------------------
### MyBatis Configuration - Cache Enabled
Source: https://mybatis.plus/config
Enables or disables MyBatis's second-level cache. Defaults to true.
```properties
cacheEnabled=true
```
--------------------------------
### MyBatis Configuration - Map Underscore to Camel Case
Source: https://mybatis.plus/config
Enables automatic mapping between database column names (snake_case) and Java property names (camelCase). This setting also affects SQL select statements generated by MyBatis-Plus.
```properties
mapUnderscoreToCamelCase=true
```
--------------------------------
### Settlement and Cache Invalidation
Source: https://mybatis.plus/guide/building-the-database-layer-of-a-high-concurrency-online-gambling-platform-using-mybatis-plus
Handles the settlement process, including database updates and subsequent cache invalidation for related data. Ensures that stale data is not served after settlement.
```java
@Transactional public boolean settleAndInvalidate(Long orderId) { boolean ok = settlementService.doSettle(orderId); // 结算落库 if (ok) { redis.del("ORDER_DETAIL:" + orderId); redis.del("ORDER_LIST:" + getUserIdByOrder(orderId)); } return ok; }
```
--------------------------------
### MyBatis Configuration - Aggressive Lazy Loading
Source: https://mybatis.plus/config
When enabled, lazy-loaded objects may have all their lazy properties loaded at once. This setting requires `lazyLoadingEnabled` to be active.
```properties
aggressiveLazyLoading=true
```
--------------------------------
### Optimistic Locking with Retries in MyBatis-Plus
Source: https://mybatis.plus/guide/building-the-database-layer-of-a-high-concurrency-online-gambling-platform-using-mybatis-plus
Handles concurrent updates to critical resources like wallet balances by implementing optimistic locking with a version field. Includes a retry mechanism with random backoff for failed updates due to version conflicts.
```java
@Transactional public boolean debitWithRetry(Long userId, BigDecimal amount) { for (int i = 0; i < 3; i++) { Wallet w = lambdaQuery().eq(Wallet::getUserId, userId).one(); if (w == null || w.getBalance().compareTo(amount) < 0) return false; w.setBalance(w.getBalance().subtract(amount)); if (updateById(w)) return true; // version 命中即成功 try { Thread.sleep(20L * (i + 1)); } catch (InterruptedException ignored) {} } return false; }
```
--------------------------------
### Cache Invalidation After Database Write
Source: https://mybatis.plus/guide/building-the-database-layer-of-a-high-concurrency-online-gambling-platform-using-mybatis-plus
Demonstrates invalidating relevant Redis caches after a successful database write operation to maintain data consistency. This is crucial for scenarios requiring strong consistency.
```java
// 写库成功后删缓存(键名示例:ORDER_LIST:userId) @Transactional public void createOrderAndInvalidateCache(BetOrder req) { save(req); // DB 写入 redis.del("ORDER_LIST:" + req.getUserId()); // 失效相关缓存 }
```
--------------------------------
### MyBatis Configuration - Local Cache Scope
Source: https://mybatis.plus/config
Configures the scope of MyBatis's first-level cache. SESSION (default) caches within a session, while STATEMENT disables the cache for each statement.
```properties
localCacheScope=SESSION
```
--------------------------------
### MyBatis Configuration - Default Enum Type Handler
Source: https://mybatis.plus/config
Specifies the default TypeHandler for enums. Options include storing enum names, ordinal values, or using custom handlers for enums implementing IEnum or marked with @EnumValue.
```properties
defaultEnumTypeHandler=org.apache.ibatis.type.EnumTypeHandler
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.