Class DatasourceOperations
java.lang.Object
org.apache.polaris.persistence.relational.jdbc.DatasourceOperations
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Constructor Summary
ConstructorsConstructorDescriptionDatasourceOperations(DataSource datasource, DatabaseType databaseType, RelationalJdbcConfiguration relationalJdbcConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionexecute(Connection connection, QueryGenerator.PreparedQuery preparedQuery) voidexecuteScript(String scriptFilePath) Execute SQL script<T> List<T> executeSelect(QueryGenerator.PreparedQuery query, Converter<T> converterInstance) Executes SELECT Query and returns the results after applying a transformer<T> voidexecuteSelectOverStream(QueryGenerator.PreparedQuery query, Converter<T> converterInstance, Consumer<Stream<T>> consumer) Executes SELECT Query and takes a consumer over the results.intexecuteUpdate(QueryGenerator.PreparedQuery preparedQuery) Executes the UPDATE or INSERT QuerybooleanvoidTransaction callback to be executed.
-
Constructor Details
-
DatasourceOperations
public DatasourceOperations(DataSource datasource, DatabaseType databaseType, RelationalJdbcConfiguration relationalJdbcConfiguration)
-
-
Method Details
-
getDatabaseType
-
executeScript
Execute SQL script- Parameters:
scriptFilePath- : Path of SQL script.- Throws:
SQLException- : Exception while executing the script.
-
executeSelect
public <T> List<T> executeSelect(@Nonnull QueryGenerator.PreparedQuery query, @Nonnull Converter<T> converterInstance) throws SQLException Executes SELECT Query and returns the results after applying a transformer- Type Parameters:
T- : Business entity class- Parameters:
query- : Query to executedconverterInstance- : An instance of the type being selected, used to convert to a business entity like PolarisBaseEntity- Returns:
- The list of results yielded by the query
- Throws:
SQLException- : Exception during the query execution.
-
executeSelectOverStream
public <T> void executeSelectOverStream(@Nonnull QueryGenerator.PreparedQuery query, @Nonnull Converter<T> converterInstance, @Nonnull Consumer<Stream<T>> consumer) throws SQLException Executes SELECT Query and takes a consumer over the results. For callers that want more sophisticated control over how query results are handled.- Type Parameters:
T- : Entity class- Parameters:
query- : Query to executedconverterInstance- : An entity of the type being selectedconsumer- : An function to consume the returned results- Throws:
SQLException- : Exception during the query execution.
-
executeUpdate
Executes the UPDATE or INSERT Query- Parameters:
preparedQuery- : query to be executed- Returns:
- : Number of rows modified / inserted.
- Throws:
SQLException- : Exception during Query Execution.
-
runWithinTransaction
public void runWithinTransaction(DatasourceOperations.TransactionCallback callback) throws SQLException Transaction callback to be executed.- Parameters:
callback- : TransactionCallback to be executed within transaction- Throws:
SQLException- : Exception caught during transaction execution.
-
execute
public Integer execute(Connection connection, QueryGenerator.PreparedQuery preparedQuery) throws SQLException - Throws:
SQLException
-
isConstraintViolation
-