Interface SessionStateDialect
- All Known Implementing Classes:
AbstractJdbcDialect,H2Dialect,MysqlDialect,PostgresDialect,SqliteDialect
public interface SessionStateDialect
Table-domain dialect interface for the session-state table.
Stores agent state keyed by (session_id, state_key, item_index).
Single states use item_index = 0; list states use one row per element.
Method names are prefixed with sessionState to avoid collision when
the aggregate class implements multiple table-domain interfaces.
Secondary index: the frequent WHERE session_id = ? and
session_id LIKE 'prefix%' queries require an index on session_id. Where
the database supports it (MySQL), vendors inline INDEX idx_session (session_id)
in the CREATE TABLE statement; the others append an idempotent
CREATE INDEX IF NOT EXISTS as a second element of the
sessionStateCreateTableDdls() list.
- Author:
- shanhongyu
-
Method Summary
Modifier and TypeMethodDescriptionsessionStateCheckTableExists(String tableName) Table-existence probe SQL.DDL statements (one or more) to create the sessions table.default BoundSqlsessionStateDeleteByKey(String sessionId, String stateKey) DELETE all items for a state key.default BoundSqlsessionStateDeleteSession(String sessionId) DELETE an entire session.default BoundSqlsessionStateExists(String sessionId) Session-existence probe.default BoundSqlsessionStateInsert(String sessionId, String stateKey, int itemIndex, String stateData) INSERT for list items (one row per element).default BoundSqlsessionStateInsertIfAbsent(String sessionId, String stateKey, int itemIndex, String stateData) INSERT of a single state withversion = 1.default charEscape character for LIKE patterns insessionStateListSessionIds(java.lang.String).default BoundSqlsessionStateListSessionIds(String prefixPattern) List distinct session IDs matching a prefix pattern.default BoundSqlsessionStateSelect(String sessionId, String stateKey, int itemIndex) Single-state SELECT by item_index.default BoundSqlsessionStateSelectList(String sessionId, String stateKey) Ordered list SELECT.default BoundSqlsessionStateSelectMaxIndex(String sessionId, String stateKey) MAX(item_index) for change detection.default BoundSqlsessionStateSelectVersioned(String sessionId, String stateKey, int itemIndex) Single-state SELECT with optimistic-concurrency version.default StringBase table name (without prefix).default BoundSqlsessionStateUpdateIfVersion(String sessionId, String stateKey, int itemIndex, String stateData, long expectedVersion) Compare-and-swap UPDATE guarded byversion == expectedVersion.sessionStateUpsert(String sessionId, String stateKey, int itemIndex, String stateData) UPSERT a single state value.
-
Method Details
-
sessionStateTableName
Base table name (without prefix). -
sessionStateCreateTableDdls
DDL statements (one or more) to create the sessions table. Must be idempotent. -
sessionStateUpsert
UPSERT a single state value. On conflict, updates state_data. -
sessionStateCheckTableExists
Table-existence probe SQL. One bind param: the table name. -
sessionStateInsert
default BoundSql sessionStateInsert(String sessionId, String stateKey, int itemIndex, String stateData) INSERT for list items (one row per element). -
sessionStateInsertIfAbsent
default BoundSql sessionStateInsertIfAbsent(String sessionId, String stateKey, int itemIndex, String stateData) INSERT of a single state withversion = 1. Used bysaveIfVersionwhenexpectedVersion == 0(create-if-absent); on a primary-key conflict the caller falls back tosessionStateUpdateIfVersion(java.lang.String, java.lang.String, int, java.lang.String, long)withexpectedVersion = 0so that rows backfilled at version 0 still satisfy the CAS, and maps a non-zero-version mismatch toAgentStateStore.UNVERSIONED. -
sessionStateUpdateIfVersion
default BoundSql sessionStateUpdateIfVersion(String sessionId, String stateKey, int itemIndex, String stateData, long expectedVersion) Compare-and-swap UPDATE guarded byversion == expectedVersion. -
sessionStateSelect
Single-state SELECT by item_index. Projection: state_data. -
sessionStateSelectVersioned
Single-state SELECT with optimistic-concurrency version. Projection: state_data, version. -
sessionStateSelectList
Ordered list SELECT. Projection: state_data. -
sessionStateDeleteByKey
DELETE all items for a state key. -
sessionStateDeleteSession
DELETE an entire session. -
sessionStateSelectMaxIndex
MAX(item_index) for change detection. Returns NULL when no rows exist. -
sessionStateExists
Session-existence probe. -
sessionStateListSessionIds
List distinct session IDs matching a prefix pattern. -
sessionStateLikeEscapeChar
default char sessionStateLikeEscapeChar()Escape character for LIKE patterns insessionStateListSessionIds(java.lang.String).
-