/**
 * 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.internal.hibernate.dialect;

import java.sql.Types;

import org.hibernate.dialect.Oracle12cDialect;

public class OracleDialect extends Oracle12cDialect {

	public OracleDialect() {
		super();
		registerColumnType(Types.LONGVARCHAR, "clob");
	}
}

@@ -771,16 +771,39 @@
 l.Types;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -847,147 +847,1766 @@
 ct;%0A
-%0Apublic class OracleDialect extends Oracle12cDialect %7B%0A%0A%09public OracleDialect() %7B%0A%09%09super();%0A%09%09registerColumnType(Types.LONGVARCHAR, %22clob%22
+import org.hibernate.dialect.function.StandardSQLFunction;%0Aimport org.hibernate.engine.spi.SessionFactoryImplementor;%0Aimport org.hibernate.type.StandardBasicTypes;%0Aimport org.hibernate.type.Type;%0A%0Apublic class OracleDialect extends Oracle12cDialect %7B%0A%0A%09static class JsonValueFunction extends StandardSQLFunction %7B%0A%0A%09%09private String returning;%0A%0A%09%09public JsonValueFunction(Type registeredType, String returning) %7B%0A%09%09%09super(%22json_value%22, registeredType);%0A%09%09%09this.returning = returning;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09@SuppressWarnings(%22rawtypes%22)%0A%09%09public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) %7B%0A%09%09%09final StringBuilder buf = new StringBuilder();%0A%09%09%09buf.append(getName()).append('(');%0A%09%09%09buf.append(arguments.get(0));%0A%09%09%09buf.append(%22, '$.%22);%0A%09%09%09for (int i = 1; i %3C arguments.size(); i++) %7B%0A%09%09%09%09final String argument = (String) arguments.get(i);%0A%09%09%09%09buf.append(argument.substring(1, argument.length() - 1));%0A%09%09%09%09if (i %3C arguments.size() - 1) %7B%0A%09%09%09%09%09buf.append(%22.%22);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09buf.append(%22'%22);%0A%09%09%09if (returning != null) %7B%0A%09%09%09%09buf.append(%22 returning %22).append(returning);%0A%09%09%09%7D%0A%09%09%09buf.append(')');%0A%09%09%09return buf.toString();%0A%09%09%7D%0A%09%7D%0A%0A%09public OracleDialect() %7B%0A%09%09super();%0A%09%09registerColumnType(Types.LONGVARCHAR, %22clob%22);%0A%09%09registerFunction(%22json_extract%22, new JsonValueFunction(StandardBasicTypes.STRING, null));%0A%09%09registerFunction(%22json_extract_text%22, new JsonValueFunction(StandardBasicTypes.STRING, null));%0A%09%09registerFunction(%22json_extract_boolean%22, new JsonValueFunction(StandardBasicTypes.BOOLEAN, %22number%22));%0A%09%09registerFunction(%22json_extract_integer%22, new JsonValueFunction(StandardBasicTypes.INTEGER, %22number%22));%0A%09%09registerFunction(%22json_extract_decimal%22, new JsonValueFunction(StandardBasicTypes.BIG_DECIMAL, %22number%22)
 );%0A%09

Implement proper json field support for oracle