Implementation:APIJSON APIJSON Demo DemoSQLConfig ES
| Knowledge Sources | |
|---|---|
| Domains | Database, Elasticsearch, SQL_Generation |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Concrete tool for configuring SQL generation with dynamic Elasticsearch data source resolution and UUID-based ID generation in the APIJSON Elasticsearch multi-datasource demo.
Description
The DemoSQLConfig class (Elasticsearch variant) extends APIJSONSQLConfig<Object> with a SimpleCallback that creates new DemoSQLConfig instances and generates UUID-based IDs for non-system tables. It overrides getDBVersion and getDBUri to resolve connection details dynamically from DynamicJdbcDataSource by datasource name. It also registers a table-name mapping for ES_blog.
Usage
Use this class when the APIJSON Elasticsearch demo needs to generate SQL for dynamically resolved Elasticsearch or JDBC data sources.
Code Reference
Source Location
- Repository: APIJSON_APIJSON_Demo
- File: APIJSON-Java-Server/APIJSONDemo-MultiDataSource-Elasticsearch/src/main/java/apijson/demo/DemoSQLConfig.java
- Lines: 1-137
Signature
public class DemoSQLConfig extends APIJSONSQLConfig<Object> {
static {
TABLE_KEY_MAP.put("ES_blog", "es_blog");
SIMPLE_CALLBACK = new SimpleCallback<String>() {
@Override
public AbstractSQLConfig getSQLConfig(RequestMethod method, String database, String schema,
String datasource, String table);
@Override
public String newId(RequestMethod method, String database, String schema, String datasource, String table);
};
}
@Override
public String getDBVersion();
@Override
public String getDBUri();
}
Import
import apijson.demo.DemoSQLConfig;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| datasource | String | No | Datasource name for dynamic resolution |
| table | String | Yes | Target table name |
Outputs
| Name | Type | Description |
|---|---|---|
| getDBVersion() returns | String | Database version from DynamicJdbcDataSource |
| getDBUri() returns | String | JDBC URI from DynamicJdbcDataSource |
| newId() returns | String | UUID string for new records |
Usage Examples
Dynamic Datasource Query
// APIJSON request using dynamic ES datasource
{
"[]": {
"ES_blog": {
"title$": "%search%"
}
}
}
// DemoSQLConfig resolves datasource details from DynamicJdbcDataSource