Search in sources :

Example 1 with DbSqlSession

use of org.camunda.bpm.engine.impl.db.sql.DbSqlSession in project camunda-bpm-platform by camunda.

the class DatabaseTableSchemaTest method testTablePresentWithSchemaAndPrefix.

public void testTablePresentWithSchemaAndPrefix() throws SQLException {
    PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", "");
    Connection connection = pooledDataSource.getConnection();
    connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME);
    connection.createStatement().execute("create schema " + SCHEMA_NAME);
    connection.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));");
    connection.close();
    ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1").setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
    config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME);
    config1.setDatabaseSchema(SCHEMA_NAME);
    config1.setDbMetricsReporterActivate(false);
    ProcessEngine engine = config1.buildProcessEngine();
    CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class);
            assertTrue(sqlSession.isTablePresent("SOME_TABLE"));
            return null;
        }
    });
    engine.close();
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Connection(java.sql.Connection) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) PooledDataSource(org.apache.ibatis.datasource.pooled.PooledDataSource) ProcessEngine(org.camunda.bpm.engine.ProcessEngine) DbSqlSession(org.camunda.bpm.engine.impl.db.sql.DbSqlSession)

Aggregations

Connection (java.sql.Connection)1 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)1 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 DbSqlSession (org.camunda.bpm.engine.impl.db.sql.DbSqlSession)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)1