diff options
Diffstat (limited to 'sonar-core')
8 files changed, 37 insertions, 7 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/Derby.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/Derby.java index 7f17ac50a67..b0c0ec5614d 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/Derby.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/Derby.java @@ -35,6 +35,10 @@ public class Derby implements Dialect { return "derby"; } + public String getActiveRecordDialectCode() { + return "derby"; + } + public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() { return DerbyWithDecimalDialect.class; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/Dialect.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/Dialect.java index b2537a36096..0f860ae4e32 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/Dialect.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/Dialect.java @@ -1,6 +1,6 @@ /* * 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 @@ -35,6 +35,11 @@ public interface Dialect { 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 * * @param jdbcConnectionURL a jdbc driver url such as jdbc:mysql://localhost:3306/sonar diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java index e5ffebe4477..b6bb3a68392 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/HsqlDb.java @@ -1,6 +1,6 @@ /* * 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 @@ -31,6 +31,10 @@ public class HsqlDb implements Dialect { return "hsqldb"; } + public String getActiveRecordDialectCode() { + return "hsqldb"; + } + public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() { return HSQLDialect.class; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/MsSql.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/MsSql.java index 764e8a57324..f59c2ee4240 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/MsSql.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/MsSql.java @@ -1,6 +1,6 @@ /* * 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 @@ -32,6 +32,10 @@ public class MsSql implements Dialect { return "mssql"; } + public String getActiveRecordDialectCode() { + return "sqlserver"; + } + public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() { return MsSqlDialect.class; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/MySql.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/MySql.java index e062e61aa4f..180dec0b1ee 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/MySql.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/MySql.java @@ -1,6 +1,6 @@ /* * 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 @@ -34,6 +34,10 @@ public class MySql implements Dialect { return "mysql"; } + public String getActiveRecordDialectCode() { + return "mysql"; + } + public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() { return MySqlWithDecimalDialect.class; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/Oracle.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/Oracle.java index 221848bb0a7..ebec6753619 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/Oracle.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/Oracle.java @@ -1,6 +1,6 @@ /* * 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 @@ -34,6 +34,10 @@ public class Oracle implements Dialect { return "oracle"; } + public String getActiveRecordDialectCode() { + return "oracle"; + } + public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() { return Oracle10gWithDecimalDialect.class; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/dialect/PostgreSql.java b/sonar-core/src/main/java/org/sonar/jpa/dialect/PostgreSql.java index 65f3436ca33..7d7318e51eb 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dialect/PostgreSql.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dialect/PostgreSql.java @@ -1,6 +1,6 @@ /* * 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 @@ -33,6 +33,10 @@ public class PostgreSql implements Dialect { return "postgresql"; } + public String getActiveRecordDialectCode() { + return "postgre"; + } + public Class<? extends org.hibernate.dialect.Dialect> getHibernateDialectClass() { return PostgreSQLWithDecimalDialect.class; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/AbstractDatabaseConnector.java b/sonar-core/src/main/java/org/sonar/jpa/session/AbstractDatabaseConnector.java index 3ba4cbc5d47..ba3e77928fa 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/session/AbstractDatabaseConnector.java +++ b/sonar-core/src/main/java/org/sonar/jpa/session/AbstractDatabaseConnector.java @@ -21,6 +21,7 @@ package org.sonar.jpa.session; 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; @@ -154,7 +155,7 @@ public abstract class AbstractDatabaseConnector implements DatabaseConnector { 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()); |