AS AgentScopeAPI 手册 / API Reference

JdbcStoreDialect

public interface JdbcStoreDialect
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:50–180

定义 JDBC 存储 Dialect契约的接口。位于 io.agentscope.extensions.mysql.store 包。核心成员包括 getCreateTableSql、getUpsertSql、getInsertSql、getCasUpdateSql、getSelectSql、getDeleteSql。

Database-specific SQL for JdbcStore.

Each dialect renders the four SQL statements that vary between vendors:

  • #getCreateTableSql — schema bootstrap, used when JdbcStore.Builder#initializeSchema(true) is set.

  • #getUpsertSql — unconditional write that increments version on update.

  • #getInsertSql — create-only insert, used by the BaseStore#putIfVersion CAS path when expectedVersion == 0; primary-key conflicts indicate the row already exists.

  • #getCasUpdateSql — conditional update used by the BaseStore#putIfVersion CAS path when expectedVersion > 0; relies on WHERE version = ? returning zero rows on mismatch.

The fixed-shape SQL statements (#getSelectSql, #getDeleteSql, #getSearchSql) have safe defaults in this interface.

All SQL templates use the %s placeholder for the table name so that callers can customise it via JdbcStore.Builder#tableName.

字段摘要Field Summary

字段Field类型Type说明Description
LOG
Logger
日志字段。
The LOG field.

方法摘要Method Summary

方法Method说明Description
public String getCreateTableSql()
获取 `getCreateTableSql`。
Returns the SQL to create the store table if it does not yet exist.
public String getUpsertSql()
获取 `getUpsertSql`。
Returns the SQL to insert-or-update an item, incrementing `version` on update.
public String getInsertSql()
获取插入 SQL。
Returns the SQL to insert a new row with `version=1`.
public String getCasUpdateSql()
获取 `getCasUpdateSql`。
Returns the SQL to conditionally update an item only when the stored version matches.
default public String getSelectSql()
default
获取选择 SQL。
Returns the SQL to fetch a single item.
default public String getDeleteSql()
default
获取删除 SQL。
Returns the SQL to delete a single item.
default public String getSearchSql()
default
获取搜索 SQL。
Returns the SQL to list items whose namespace_path matches a `LIKE` pattern.
default public char getLikeEscapeChar()
default
获取 `getLikeEscapeChar`。
The escape character paired with `#getSearchSql`'s `ESCAPE` clause.
static public JdbcStoreDialect from(DataSource dataSource)
static
创建并返回实例。
Detects the dialect from the `DataSource`'s database product name.

字段详情Field Detail

LOG

Logger LOG

日志字段。声明为 Logger LOG。

The LOG field.

源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:52

方法详情Method Detail

getCreateTableSql

public String getCreateTableSql()

获取 getCreateTableSql。

Returns the SQL to create the store table if it does not yet exist.

返回Returns String
返回字符串结果。CREATE TABLE statement; must use `%s` for the table name
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:63

getUpsertSql

public String getUpsertSql()

获取 getUpsertSql。

Returns the SQL to insert-or-update an item, incrementing version on update.

返回Returns String
返回字符串结果。UPSERT statement; must use `%s` for the table name
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:74

getInsertSql

public String getInsertSql()

获取插入 SQL。

Returns the SQL to insert a new row with version=1.

返回Returns String
返回字符串结果。INSERT statement; must use `%s` for the table name
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:85

getCasUpdateSql

public String getCasUpdateSql()

获取 getCasUpdateSql。

Returns the SQL to conditionally update an item only when the stored version matches.

返回Returns String
返回字符串结果。UPDATE statement; must use `%s` for the table name
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:97

getSelectSql

default public String getSelectSql()
default

获取选择 SQL。

Returns the SQL to fetch a single item.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:105–107

getDeleteSql

default public String getDeleteSql()
default

获取删除 SQL。

Returns the SQL to delete a single item.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:114–116

getSearchSql

default public String getSearchSql()
default

获取搜索 SQL。

Returns the SQL to list items whose namespace_path matches a LIKE pattern.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:130–134

getLikeEscapeChar

default public char getLikeEscapeChar()
default

获取 getLikeEscapeChar。

The escape character paired with #getSearchSql's ESCAPE clause.

返回Returns char
返回char。Returns char.
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:141–143

from

static public JdbcStoreDialect from(DataSource dataSource)
static

创建并返回实例。

Detects the dialect from the DataSource's database product name.

参数Parameters
名称Name类型Type说明Description
dataSourceDataSourceJDBC 数据来源到探针;必须不为`null`。the JDBC data source to probe; must not be `null`
返回Returns JdbcStoreDialect
返回JdbcStoreDialect。a dialect appropriate for the underlying database
源码Source io/agentscope/extensions/mysql/store/JdbcStoreDialect.java:154–179
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.