public class DefaultJdbcDatastore extends com.holonplatform.core.internal.datastore.AbstractInitializableDatastore<JdbcDatastoreCommodityContext> implements JdbcDatastore, JdbcDatastoreCommodityContext
JdbcDatastore implementation.
The Datastore instance must be initialized using the AbstractInitializableDatastore.initialize() method before using it.
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultJdbcDatastore.AbstractBuilder<D extends JdbcDatastore,I extends DefaultJdbcDatastore>
Base
JdbcDatastore builder. |
static class |
DefaultJdbcDatastore.DefaultBuilder
Default
JdbcDatastore builder. |
JdbcDatastore.Builder<D extends JdbcDatastore>com.holonplatform.core.datastore.Datastore.OperationResult, com.holonplatform.core.datastore.Datastore.OperationType| Constructor and Description |
|---|
DefaultJdbcDatastore()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<com.holonplatform.jdbc.DataSourceConfigProperties> |
getConfiguration()
Get the data source configuration properties.
|
Optional<com.holonplatform.jdbc.DatabasePlatform> |
getDatabase()
Get the database type to which
DataSource is connected. |
DataSource |
getDataSource()
Get the
DataSource bound to the datastore. |
SQLDialect |
getDialect()
Get the
SQLDialect to use. |
IdentifierResolutionStrategy |
getIdentifierResolutionStrategy()
Get the
IdentifierResolutionStrategy. |
PreparedStatement |
prepareInsertStatement(SQLStatement statement,
Connection connection,
SQLPrimaryKey primaryKey)
Create and configure a
PreparedStatement for an INSERT type operation, using given
SQLStatement and connection. |
PreparedStatement |
prepareStatement(SQLStatement statement,
Connection connection)
Create and configure a
PreparedStatement using given SQLStatement and connection. |
void |
setConfiguration(com.holonplatform.jdbc.DataSourceConfigProperties configuration,
boolean buildDataSource)
Set the data source configuration properties.
|
void |
setConnectionHandler(com.holonplatform.jdbc.JdbcConnectionHandler connectionHandler)
Set the
JdbcConnectionHandler to be used for Datastore JDBC connections handling. |
void |
setDatabase(com.holonplatform.jdbc.DatabasePlatform database)
Set the database platform
|
void |
setDataSource(DataSource dataSource)
Set the
DataSource to be used by this datastore to perform database operations. |
void |
setDialect(SQLDialect dialect)
Set the SQL dialect
|
void |
setIdentifierResolutionStrategy(IdentifierResolutionStrategy identifierResolutionStrategy)
Set the
IdentifierResolutionStrategy. |
void |
setTransactionFactory(JdbcTransactionFactory transactionFactory)
Set the
JdbcTransactionFactory to use to create a new JDBC transaction. |
void |
trace(String sql)
Trace given SQL statement.
|
<R> R |
withConnection(ConnectionOperation<R> operation)
Execute given
ConnectionOperation using a managed connection. |
<R> R |
withSharedConnection(Supplier<R> operations)
Execute given operations using a shared connection.
|
<R> R |
withTransaction(com.holonplatform.core.datastore.transaction.TransactionalOperation<R> operation,
com.holonplatform.core.datastore.transaction.TransactionConfiguration transactionConfiguration) |
getInitializationClassLoader, initialize, isInitialized, setInitializationClassLoaderaddExpressionResolver, create, getAvailableCommodities, getCommodityFactoryType, getDataContextId, getExpressionResolvers, getExpressionResolverType, isTraceEnabled, registerCommodity, removeExpressionResolver, resolve, setDataContextId, setTraceEnabled, toStringequals, getClass, hashCode, notify, notifyAll, wait, wait, waitbuilderbulkDelete, bulkInsert, bulkUpdate, delete, insert, isTransactional, query, query, refresh, requireTransactional, save, updatecreate, getAvailableCommodities, hasCommodityaddExpressionResolver, addExpressionResolvers, removeExpressionResolverwithTransaction, withTransaction, withTransactiongetCommodityFactoryType, registerCommoditygetStatementConfiguratorgetTypeConverter, getValueDeserializer, getValueSerializergetExpressionResolverswithConnectionpublic void setTransactionFactory(JdbcTransactionFactory transactionFactory)
JdbcTransactionFactory to use to create a new JDBC transaction.transactionFactory - the transaction factory to set (not null)public Optional<com.holonplatform.jdbc.DataSourceConfigProperties> getConfiguration()
public void setConfiguration(com.holonplatform.jdbc.DataSourceConfigProperties configuration,
boolean buildDataSource)
configuration - the data source configuration properties to set (not null)buildDataSource - Whether to build and set a DataSource using given configuration properties.public void setDataSource(DataSource dataSource)
DataSource to be used by this datastore to perform database operations.dataSource - the DataSource to set (not null)public DataSource getDataSource()
JdbcDatastoreCommodityContextDataSource bound to the datastore.getDataSource in interface JdbcDatastoreCommodityContextpublic void setConnectionHandler(com.holonplatform.jdbc.JdbcConnectionHandler connectionHandler)
JdbcConnectionHandler to be used for Datastore JDBC connections handling.connectionHandler - The connection handler to set (not null)public Optional<com.holonplatform.jdbc.DatabasePlatform> getDatabase()
JdbcDatastoreCommodityContextDataSource is connected.getDatabase in interface JdbcDatastoreCommodityContextDatabasePlatform of the DataSource database, empty if not availablepublic void setDatabase(com.holonplatform.jdbc.DatabasePlatform database)
database - the database platform to setpublic SQLDialect getDialect()
SQLContextSQLDialect to use.getDialect in interface SQLContextpublic void setDialect(SQLDialect dialect)
dialect - the dialect to setpublic IdentifierResolutionStrategy getIdentifierResolutionStrategy()
JdbcOperationContextIdentifierResolutionStrategy.getIdentifierResolutionStrategy in interface JdbcOperationContextpublic void setIdentifierResolutionStrategy(IdentifierResolutionStrategy identifierResolutionStrategy)
IdentifierResolutionStrategy.identifierResolutionStrategy - the identifier resolution strategy to set (not null)public <R> R withSharedConnection(Supplier<R> operations)
JdbcOperationContextwithSharedConnection in interface JdbcOperationContextR - Operation result typeoperations - Operations to execute (not null)public <R> R withConnection(ConnectionOperation<R> operation)
ConnectionHandlerConnectionOperation using a managed connection.withConnection in interface ConnectionHandlerR - Operation result typeoperation - Operation to execute (not null)public <R> R withTransaction(com.holonplatform.core.datastore.transaction.TransactionalOperation<R> operation,
com.holonplatform.core.datastore.transaction.TransactionConfiguration transactionConfiguration)
withTransaction in interface com.holonplatform.core.datastore.transaction.Transactionalpublic PreparedStatement prepareStatement(SQLStatement statement, Connection connection)
JdbcOperationContextPreparedStatement using given SQLStatement and connection.prepareStatement in interface JdbcOperationContextstatement - SQL statement (not null)connection - Connection (not null)PreparedStatementpublic PreparedStatement prepareInsertStatement(SQLStatement statement, Connection connection, SQLPrimaryKey primaryKey)
JdbcOperationContextPreparedStatement for an INSERT type operation, using given
SQLStatement and connection.prepareInsertStatement in interface JdbcOperationContextstatement - SQL statement (not null)connection - Connection (not null)primaryKey - Optional primary key to use to retrieve any auto-generated keyPreparedStatementpublic void trace(String sql)
SQLContext
If tracing is enabled, the SQL statement is logged using the INFO level, otherwise it is logged
using the DEBUG level.
trace in interface SQLContextsql - SQL to traceCopyright © 2019 The Holon Platform. All rights reserved.