Interface JdbcSessionRepositoryDialect
- All Known Implementing Classes:
H2JdbcSessionRepositoryDialect,MysqlJdbcSessionRepositoryDialect,PostgresJdbcSessionRepositoryDialect,SqlServerJdbcSessionRepositoryDialect
public interface JdbcSessionRepositoryDialect
The SQL that differs between databases, for
JdbcSessionRepository: the upsert
and the insert-if-absent of a session, and the clause that limits a query's rows. Every
other statement is shared and lives in the repository. from(DataSource)
detects the dialect from the database metadata.- Since:
- 2.1.0
- Author:
- Christian Tzolov
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic JdbcSessionRepositoryDialectfrom(DataSource dataSource) The dialect of the database the data source connects to, from its product name: PostgreSQL, H2, MySQL, MariaDB or Microsoft SQL Server.default StringInserts a row intoAI_SESSIONonly if its id does not exist, with the same four parameters asgetUpsertSessionSql(): one row updated on insert, zero rows or a duplicate-key error when the id exists.default StringThe predicate of a keyword search: whether the text of an event's message contains a keyword, ignoring case.default StringThe clause appended after a query'sORDER BYto keep at most as many rows as its single parameter, bound last.Inserts a row intoAI_SESSIONor updates the existing one, refreshing onlyexpires_atandmetadata:created_atkeeps its value andevent_versionis never touched.default StringtoKeywordParameter(String keyword) The value bound to the parameter ofgetKeywordPredicate()for a keyword: by default the keyword between two%, with!,%and_escaped by!, so that a keyword is matched as text and never as a pattern.
-
Method Details
-
getUpsertSessionSql
String getUpsertSessionSql()Inserts a row intoAI_SESSIONor updates the existing one, refreshing onlyexpires_atandmetadata:created_atkeeps its value andevent_versionis never touched. Parameters, in order:id,created_at,expires_at,metadata. -
getInsertSessionIfAbsentSql
Inserts a row intoAI_SESSIONonly if its id does not exist, with the same four parameters asgetUpsertSessionSql(): one row updated on insert, zero rows or a duplicate-key error when the id exists. The default is a plainINSERT; a database whose failed statement aborts the enclosing transaction, PostgreSQL always and SQL Server withXACT_ABORT ON, uses a form that inserts nothing instead. -
getLimitClause
The clause appended after a query'sORDER BYto keep at most as many rows as its single parameter, bound last. The default,LIMIT ?, serves PostgreSQL, H2, MySQL and MariaDB; a database withoutLIMITreturns its own form, such asOFFSET 0 ROWS FETCH NEXT ? ROWS ONLY. -
getKeywordPredicate
The predicate of a keyword search: whether the text of an event's message contains a keyword, ignoring case. A predicate over the event row with the aliase, with one parameter and no leadingAND; the repository repeats it per keyword and binds each parameter totoKeywordParameter(String). The default is aLIKEwith!as the escape character that lower-cases both themessage_contentand the parameter in the database, so that the two sides are folded by the same rules. It serves every supported database. -
toKeywordParameter
The value bound to the parameter ofgetKeywordPredicate()for a keyword: by default the keyword between two%, with!,%and_escaped by!, so that a keyword is matched as text and never as a pattern. A database whoseLIKEknows more wildcards escapes them too. -
from
The dialect of the database the data source connects to, from its product name: PostgreSQL, H2, MySQL, MariaDB or Microsoft SQL Server.- Throws:
IllegalStateException- if the product name cannot be read or the database is not supported; set the dialect withJdbcSessionRepository.Builder.dialect(JdbcSessionRepositoryDialect)then
-