#----- JDBC Datasource bounded to JNDI
# When sonar webapp is deployed into a JEE server, the JDBC datasource can be configured into the JEE server and registered into JNDI.
# In such a case Sonar uses this datasource to connect to database.
-# If you activate this feature, then the properties starting with "sonar.jdbc." can be commented, EXCEPT "sonar.jdbc.driverClassName".
+# If you activate this feature, then the properties starting with "sonar.jdbc." can be commented, except "sonar.jdbc.dialect".
# The JDBC driver must still be deployed into the directory /extensions/jdbc-driver.
#sonar.jdbc.jndiName: jdbc/sonar
-# If you don't use the default JDBC drivers, as listed above, then you have to explicitly set the dialect to use.
-# Values are : mysql, derby, oracle, postgresql
+# Values are : mysql, mssql, derby, oracle, postgresql
#sonar.jdbc.dialect=
return "derby";
}
+ public String getActiveRecordDialectCode() {
+ return "derby";
+ }
+
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
return DerbyWithDecimalDialect.class;
}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
+ * Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
*/
Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass();
+ /**
+ * @return the activerecord dialect to be used
+ */
+ String getActiveRecordDialectCode();
+
/**
* Used to autodetect a dialect for a given driver URL
*
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
+ * Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
return "hsqldb";
}
+ public String getActiveRecordDialectCode() {
+ return "hsqldb";
+ }
+
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
return HSQLDialect.class;
}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
+ * Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
return "mssql";
}
+ public String getActiveRecordDialectCode() {
+ return "sqlserver";
+ }
+
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
return MsSqlDialect.class;
}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
+ * Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
return "mysql";
}
+ public String getActiveRecordDialectCode() {
+ return "mysql";
+ }
+
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
return MySqlWithDecimalDialect.class;
}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
+ * Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
return "oracle";
}
+ public String getActiveRecordDialectCode() {
+ return "oracle";
+ }
+
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
return Oracle10gWithDecimalDialect.class;
}
/*
* Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
+ * Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
return "postgresql";
}
+ public String getActiveRecordDialectCode() {
+ return "postgre";
+ }
+
public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() {
return PostgreSQLWithDecimalDialect.class;
}
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.StringUtils;
+import org.hibernate.cfg.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.database.DatabaseProperties;
props.put("hibernate.connection.isolation", Integer.toString(transactionIsolation));
}
props.put("hibernate.hbm2ddl.auto", getConfiguration().getString(DatabaseProperties.PROP_HIBERNATE_HBM2DLL, "validate"));
- props.put("hibernate.dialect", getDialectClass());
+ props.put(Environment.DIALECT, getDialectClass());
props.put("hibernate.generate_statistics", getConfiguration().getBoolean(DatabaseProperties.PROP_HIBERNATE_GENERATE_STATISTICS, false));
props.put("hibernate.show_sql", Boolean.valueOf(LOG_SQL.isInfoEnabled()).toString());
@config[:connection_alive_sql] ||= ::Java::OrgSonarServerUi::JRubyFacade.getInstance().getConfigurationValue('sonar.jdbc.validationQuery')
@jndi_connection = true # used in JndiConnectionPoolCallbacks to close this initial connection
-
+
@connection_factory = JdbcConnectionFactory.impl do
::Java::OrgSonarServerUi::JRubyFacade.getInstance().getConnection()
end
- @config[:driver] = ::Java::OrgSonarServerUi::JRubyFacade.getInstance().getConfigurationValue('sonar.jdbc.driverClassName')
+ @config[:dialect] = ::Java::OrgSonarServerUi::JRubyFacade.getInstance().getDialect().getActiveRecordDialectCode()
connection # force the connection to load
set_native_database_types
class ActiveRecord::Migration
def self.alter_to_big_primary_key(tablename)
- dialect = ActiveRecord::Base.configurations[ ENV['RAILS_ENV'] ]["dialect"]
+ dialect = ::Java::OrgSonarServerUi::JRubyFacade.getInstance().getDialect().getActiveRecordDialectCode()
case dialect
when "postgre"
execute "ALTER TABLE #{tablename} ALTER COLUMN id TYPE bigint"