/*
 * Axelor Business Solutions
 *
 * Copyright (C) 2005-2017 Axelor (<http://axelor.com>).
 *
 * This program is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.axelor.db.hibernate.dialect;

import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.internal.StandardDialectResolver;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CustomDialectResolver extends StandardDialectResolver {

	private static final long serialVersionUID = 8211296180497513187L;
	
	private static final Logger log = LoggerFactory.getLogger(CustomDialectResolver.class);

	public static final CustomDialectResolver INSTANCE = new CustomDialectResolver();

	@Override
	public Dialect resolveDialect(DialectResolutionInfo info) {
		final String databaseName = info.getDatabaseName();
		final int majorVersion = info.getDatabaseMajorVersion();
		final int minorVersion = info.getDatabaseMinorVersion();
		if ("HSQL Database Engine".equals(databaseName)) {
			return new HSQLDialect();
		}
		if ("PostgreSQL".equals(databaseName)) {
			if (majorVersion >= 9 && minorVersion >= 4) {
				return new PostgreSQLDialect();
			}
			log.error("PostgreSQL 9.4 or later is required.");
		}
		if ("Oracle".equals(databaseName)) {
			if (majorVersion > 11) {
				return new OracleDialect();
			}
			log.error("Oracle 12c or later is required.");
		}
		if ("MySQL".equals(databaseName)) {
			if (majorVersion >= 5 && minorVersion >= 7) {
				return new MySQLDialect();
			}
			log.error("MySQL 5.7 or later is required.");
		}
		log.error("{} {}.{} is not suppported.", databaseName, majorVersion, minorVersion);
		return null;
	}
}

@@ -1663,32 +1663,33 @@
 eName)) %7B%0A%09%09%09if 
+(
 (majorVersion %3E=
@@ -1712,16 +1712,39 @@
 on %3E= 4)
+ %7C%7C majorVersion %3E= 10)
  %7B%0A%09%09%09%09r

Add support for PostgreSQL 10.x