AnsweredAssumed Answered

Postgres SQL schema name inconsistency

Question asked by deg on Sep 24, 2014
Latest reply on Sep 25, 2014 by deg
My dev evironment uses activiti 5.16.3 on a PostGreSQL 9.3
My aciviti tables need to run in a seperate schema.

I lost some time due to the fact that i gave the schema an name in uppercase. Activiti always converts the entire tablename, incuding the database schema prefix, to lowercase when trying to connect.

In the TableDataManager


if ("postgres".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) {
        tableName = tableName.toLowerCase();
      }



Once i renamed my schema to lowercase, activiti was able to find my schema and the tables.
In my configuration i still have the prefix in uppercase.

However it then crashes during the dbSchemaCheck because there it does not convert the tablenames to lower case.

Caused by: org.activiti.engine.ActivitiException: Activiti database problem: Tables missing for component(s) engine, history, identity
   at org.activiti.engine.impl.db.DbSqlSession.dbSchemaCheckVersion(DbSqlSession.java:892) [activiti-engine-5.16.3.jar:5.16.3]
   at org.activiti.engine.impl.db.DbSqlSession.performSchemaOperationsProcessEngineBuild(DbSqlSession.java:1366) [activiti-engine-5.16.3.jar:5.16.3]

This is because in the DbSqlSession the table name is converted to lower case, but the schema name is not.
Which is rather inconsistent.


  public boolean isEngineTablePresent(){
    return isTablePresent("ACT_RU_EXECUTION");
  }
  public boolean isHistoryTablePresent(){
    return isTablePresent("ACT_HI_PROCINST");
  }
  public boolean isIdentityTablePresent(){
    return isTablePresent("ACT_ID_USER");
  }
 
   public boolean isTablePresent(String tableName) {
   ……..
    String schema = this.connectionMetadataDefaultSchema;
      if (dbSqlSessionFactory.getDatabaseSchema() != null && dbSqlSessionFactory.getDatabaseSchema().length() > 0) {
        schema = dbSqlSessionFactory.getDatabaseSchema();
      }
     
    String databaseType = dbSqlSessionFactory.getDatabaseType();
    if ("postgres".equals(databaseType)) {
        tableName = tableName.toLowerCase();
      }
   ……..
   }


I retrieve the schemaname via JNDI lookup so i will be able to obtain the correct schema name depending on the environment the application runs. But i suspect this is not intended behaviour.

Outcomes