Index: src/main/java/org/sonar/commons/database/dialect/PostgreSQLWithDecimalDialect.java
===================================================================
--- src/main/java/org/sonar/commons/database/dialect/PostgreSQLWithDecimalDialect.java	(révision 0)
+++ src/main/java/org/sonar/commons/database/dialect/PostgreSQLWithDecimalDialect.java	(révision 0)
@@ -0,0 +1,36 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.commons.database.dialect;
+
+import java.sql.Types;
+
+import org.hibernate.dialect.PostgreSQLDialect;
+import org.sonar.commons.database.id.PostgreSQLSequenceGenerator;
+
+public class PostgreSQLWithDecimalDialect extends PostgreSQLDialect {
+  public PostgreSQLWithDecimalDialect() {
+    super();
+    registerColumnType(Types.DOUBLE, "numeric($p,$s)");
+  }
+  
+  public Class getNativeIdentifierGeneratorClass() {
+    return PostgreSQLSequenceGenerator.class;
+  }
+}
\ No newline at end of file
Index: src/main/java/org/sonar/commons/database/id/PostgreSQLSequenceGenerator.java
===================================================================
--- src/main/java/org/sonar/commons/database/id/PostgreSQLSequenceGenerator.java	(révision 0)
+++ src/main/java/org/sonar/commons/database/id/PostgreSQLSequenceGenerator.java	(révision 0)
@@ -0,0 +1,47 @@
+package org.sonar.commons.database.id;
+
+import java.util.Properties;
+
+import org.hibernate.MappingException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.id.PersistentIdentifierGenerator;
+import org.hibernate.id.SequenceGenerator;
+import org.hibernate.type.Type;
+
+/**
+ * if the underlying database is PostgreSQL, the sequence
+ * naming convention is different and includes the primary key
+ * column name
+ */
+public class PostgreSQLSequenceGenerator extends SequenceGenerator {
+
+  public static final String SEQUENCE_NAME_SEPARATOR = "_";
+  public static final String SEQUENCE_NAME_SUFFIX = "seq";
+
+  @Override
+  public void configure(Type type, Properties params, Dialect dialect)
+      throws MappingException {
+	
+    String tableName = params.getProperty(PersistentIdentifierGenerator.TABLE);
+    String columnName = params.getProperty(PersistentIdentifierGenerator.PK);
+
+    if (tableName != null) {
+      StringBuilder sequenceNameBuilder = new StringBuilder();
+
+      sequenceNameBuilder.append(tableName);
+
+      if (columnName != null) {
+        sequenceNameBuilder.append(SEQUENCE_NAME_SEPARATOR);
+        sequenceNameBuilder.append(columnName);
+      }
+
+      sequenceNameBuilder.append(SEQUENCE_NAME_SEPARATOR);
+      sequenceNameBuilder.append(SEQUENCE_NAME_SUFFIX);
+
+      params.setProperty(SEQUENCE, sequenceNameBuilder.toString());
+    }
+
+    super.configure(type, params, dialect);
+  }
+
+}

