Skip to content

Global Configuration

The Kite ORM framework provides flexible global configuration options that allow developers to customize the framework's behavior according to their needs. These configurations are mainly concentrated in three core configuration classes under the com.tang.kite.config package: KiteConfig, PageConfig, and SqlConfig.

KiteConfig

KiteConfig is the core configuration class of the Kite framework, containing the main configuration options for the framework.

Configuration Items

Configuration ItemTypeDefault ValueDescription
bannerBooleantrueWhether to display the Kite framework banner during application startup
selectiveStrategyFunction1<Any?, Boolean>DefaultSelectiveStrategy.isSelective(it)Selective query strategy, used to determine which fields should be included in SQL queries
batchSizeInt1000Batch size for operations like inserts or updates
dialectsMutableMap<DatabaseType, SqlDialect>DefaultSqlDialectFactory().getDialects()SQL dialect mappings for different database types
fillHandlersMutableMap<FillKey, FillHandler>Contains TimeFillHandler for CreateTime and UpdateTimeMapping of fill annotation handlers, used to process annotations like @CreateTime and @UpdateTime
pagePageConfigPageConfig objectPagination-related configurations, references PageConfig object
sqlSqlConfigSqlConfig objectSQL-related configurations, references SqlConfig object

Usage Examples

java
// Modify batch operation size
KiteConfig.setBatchSize(500);

// Disable startup banner
KiteConfig.setBanner(false);

// Custom method filtering strategy
KiteConfig.setSelectiveStrategy(it -> it != null);

PageConfig

PageConfig is used to configure default parameters related to pagination.

Configuration Items

Configuration ItemTypeDefault ValueDescription
pageNumberLong1Default page number
pageSizeLong10Default number of records per page
pageNumberParameterString"pageNumber"Page number parameter name, used to get the page number from requests
pageSizeParameterString"pageSize"Page size parameter name, used to get the page size from requests

Usage Examples

java
// Modify default page number to 1
PageConfig.setPageNumber(1);

// Modify default page size to 20
PageConfig.setPageSize(20);

// Modify page number parameter name to "page"
PageConfig.setPageNumberParameter("page");

// Modify page size parameter name to "size"
PageConfig.setPageSizeParameter("size");

SqlConfig

SqlConfig is used to configure SQL-related parameters and behaviors.

Configuration Items

Configuration ItemTypeDefault ValueDescription
sqlLowercaseBooleantrueWhether to use lowercase for generated SQL
sqlLoggingBooleantrueWhether to log generated SQL statements
sqlDurationLoggingBooleantrueWhether to log SQL execution time
durationUnitDurationUnitDurationUnit.MILLISECONDSUnit of SQL execution time
durationDecimalsInt0Number of decimal places for SQL execution time

Method Descriptions

Method NameParametersReturn ValueDescription
getSql(StringBuilder sql)sql: SQL string builderStringFormats SQL string according to sqlLowercase configuration
getSql(String sql)sql: SQL stringStringFormats SQL string according to sqlLowercase configuration

Usage Examples

java
// Disable SQL logging
SqlConfig.setSqlLogging(false);

// Set SQL execution time unit to seconds
SqlConfig.setDurationUnit(DurationUnit.SECONDS);

// Set SQL execution time decimal places to 2
SqlConfig.setDurationDecimals(2);

// Generate uppercase SQL
SqlConfig.setSqlLowercase(false);

Built with ❤️ by Tang