- All Known Implementing Classes:
AbstractDatabaseProvider,H2DatabaseProvider,OracleDatabaseProvider,PostgresDatabaseProvider,SQLiteDatabaseProvider,TransactionalDatabaseProvider
public interface DatabaseProvider
Main interface for interacting with a database.
This interface defines the operations for retrieving metadata, executing SQL queries, and managing data within a specific database backend.
-
Method Summary
Modifier and TypeMethodDescriptiondelete(Delete delete, ConnectionProvider connectionProvider) Execute a DELETE operation in the database using the providedDeletestatement.getSequenceColumnValueGenerator(String sequence) Retrieves aSequenceColumnValueGeneratorinstance for generating SQL fragments that fetch the next value from a specified database sequence.Retrieve theSqlFunctionRegistryinstance associated with the database provider.Retrieve theTypeConverterinstance associated with the database provider.insert(Insert insert, ConnectionProvider connectionProvider) Execute an INSERT operation in the database using the providedInsertstatement.select(Select select, ConnectionProvider connectionProvider) Execute a SELECT operation in the database using the providedSelectstatement.tableMetaData(Table table, ConnectionProvider connectionProvider) Retrieve metadata for the specified table.toSql(Operation operation, ConnectionProvider connectionProvider) Converts the givenOperationinto its corresponding SQL representation.update(Update update, ConnectionProvider connectionProvider) Execute an UPDATE operation in the database using the providedUpdatestatement.
-
Method Details
-
tableMetaData
Retrieve metadata for the specified table.- Parameters:
table- theTableobject representing the table for which metadata is to be retrieved.connectionProvider- theConnectionProviderused to get a database connection.- Returns:
- a
TableMetaDataobject containing metadata information about the specified table, including its columns, primary key, and other details. - Throws:
SQLException- if any SQL error occurs while retrieving the metadata.
-
insert
Execute an INSERT operation in the database using the providedInsertstatement.- Parameters:
insert- theInsertstatement containing the table, columns, and rows to insert.connectionProvider- theConnectionProviderused to get a database connection.- Returns:
- an
InsertResultcontaining the number of rows affected and any generated keys. - Throws:
SQLException- if any SQL error occurs during the execution of the insert operation.
-
update
Execute an UPDATE operation in the database using the providedUpdatestatement.- Parameters:
update- theUpdatestatement containing the table, columns, and rows to update.connectionProvider- theConnectionProviderused to get a database connection.- Returns:
- an
UpdateResultcontaining the number of rows affected. - Throws:
SQLException- if any SQL error occurs during the execution of the update operation.
-
select
Execute a SELECT operation in the database using the providedSelectstatement.- Parameters:
select- theSelectstatement containing information about the table, expressions, joins, conditions, ordering, and optional limits for the query.connectionProvider- theConnectionProviderused to get a database connection.- Returns:
- a
ListofRowobjects representing the results of the SELECT operation. - Throws:
SQLException- if any SQL error occurs during the execution of the SELECT operation.
-
delete
Execute a DELETE operation in the database using the providedDeletestatement.- Parameters:
delete- theDeletestatement containing the table and rows to delete.connectionProvider- theConnectionProviderused to get a database connection.- Returns:
- an
UpdateResultcontaining the number of rows affected. - Throws:
SQLException- if any SQL error occurs during the execution of the delete operation.
-
toSql
Converts the givenOperationinto its corresponding SQL representation.This does not execute the operation, it only generates the SQL string.
- Parameters:
operation- theOperationobject representing the database operation (e.g., SELECT, INSERT, UPDATE, DELETE) to be converted to a SQL string.connectionProvider- theConnectionProviderused to obtain database-specific context or information required for SQL generation, such as metadata or dialect.- Returns:
- a
Stringcontaining the SQL representation of the givenOperation.
-
getTypeConverter
TypeConverter getTypeConverter()Retrieve theTypeConverterinstance associated with the database provider.The
TypeConverteris used for converting objects between different types, typically for database data type conversions and mapping domain-specific representations.- Returns:
- the
TypeConverterinstance for handling data type conversions
-
getSequenceColumnValueGenerator
SequenceColumnValueGenerator getSequenceColumnValueGenerator(String sequence) throws UnsupportedOperationException Retrieves aSequenceColumnValueGeneratorinstance for generating SQL fragments that fetch the next value from a specified database sequence. This is typically used in SQL statements such as INSERT or UPDATE to generate unique values from a sequence.- Parameters:
sequence- the name of the database sequence from which the values will be generated. It is used to create the SQL fragment to retrieve the next value in the sequence.- Returns:
- a
SequenceColumnValueGeneratorinstance that generates SQL fragments for retrieving sequence values. - Throws:
UnsupportedOperationException- if the database provider does not support sequence-based value generation.
-
getSqlFunctionRegistry
SqlFunctionRegistry getSqlFunctionRegistry()Retrieve theSqlFunctionRegistryinstance associated with the database provider.The
SqlFunctionRegistryis used for registering and managing SQL functions that can be used in SQL queries executed by the database provider.- Returns:
- the
SqlFunctionRegistryinstance for managing SQL functions
-
getAliasTransformer
AliasTransformer getAliasTransformer()
-