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
pageNumberParameterStringpageNumberPage number parameter name, used to get the page number from requests
pageSizeParameterStringpageSizePage 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
durationLoggingBooleantrueWhether to log SQL execution time
durationUnitDurationUnitDurationUnit.MILLISECONDSUnit of SQL execution time
durationDecimalsInt0Number of decimal places for SQL execution time
prepareLoggingBooleandurationLoggingWhether to log SQL prepare time
prepareUnitDurationUnitdurationUnitUnit of SQL prepare time
prepareDecimalsIntdurationDecimalsNumber of decimal places for SQL prepare time
executionLoggingBooleandurationLoggingWhether to log SQL execution time
executionUnitDurationUnitdurationUnitUnit of SQL execution time
executionDecimalsIntdurationDecimalsNumber of decimal places for SQL execution time
mappingLoggingBooleandurationLoggingWhether to log SQL mapping time
mappingUnitDurationUnitdurationUnitUnit of SQL mapping time
mappingDecimalsIntdurationDecimalsNumber of decimal places for SQL mapping time
elapsedLoggingBooleandurationLoggingWhether to log SQL elapsed time
elapsedUnitDurationUnitdurationUnitUnit of SQL elapsed time
elapsedDecimalsIntdurationDecimalsNumber of decimal places for SQL elapsed time

Method Descriptions

Method NameParametersReturn ValueDescription
getSql(sql: StringBuilder)sql: SQL string builderStringFormats SQL string according to sqlLowercase configuration
getSql(sql: String)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);

// Configure SQL prepare time logging
SqlConfig.setPrepareLogging(true);
SqlConfig.setPrepareUnit(DurationUnit.MILLISECONDS);
SqlConfig.setPrepareDecimals(2);

// Configure SQL execution time logging
SqlConfig.setExecutionLogging(true);
SqlConfig.setExecutionUnit(DurationUnit.MILLISECONDS);
SqlConfig.setExecutionDecimals(2);

// Configure SQL mapping time logging
SqlConfig.setMappingLogging(true);
SqlConfig.setMappingUnit(DurationUnit.MILLISECONDS);
SqlConfig.setMappingDecimals(2);

// Configure SQL elapsed time logging
SqlConfig.setElapsedLogging(true);
SqlConfig.setElapsedUnit(DurationUnit.MILLISECONDS);
SqlConfig.setElapsedDecimals(2);

Released under the MIT License