/*
@see FieldConversion#javaToSql(Object)
776070
public Object javaToSql(Object source)
    {
        if (source == null)
            return null;
        try
        {
            return SerializationUtils.serialize((Serializable) source);
        }
        catch(Throwable t)
        {
            throw new ConversionException(t);
        }
    }
435597
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static final <TO, FROM> TO convert(Class<TO> to, FROM from) {

		// Convert null value
		if (from == null || to == null) {
			return null;
		}

		// Convert "null" String to null
		if ("null".equals(from)) {
			return null;
		}

		// Class is same
		if (to == Object.class || from.getClass() == to) {
			return (TO) from;
		}

		// BSON conversion
		boolean isFromMap = from != null && from instanceof Map;
		if (isFromMap) {
			Object subValue = getSubValue((Map) from);
			if (subValue != null) {
				return convert(to, subValue);
			}
		}

		// Convert FROM -> TO
		DataConverterKey<TO, FROM> key = new DataConverterKey<TO, FROM>(to, (Class<FROM>) from.getClass());
		DataConverter<TO, FROM> converter = (DataConverter<TO, FROM>) converters.get(key);
		if (converter != null) {
			return converter.convert(from);
		}

		// Convert any -> TO
		converter = (DataConverter<TO, FROM>) defaultConverters.get(to);
		if (converter != null) {
			return converter.convert(from);
		}

		// Converter not found
		throw new IllegalArgumentException("Unable to convert " + from.getClass() + " to " + to
				+ ", converter not found in DataConverterRegistry!");
	}
1279608
@Override
	public Object toJdbc(final Enum<?> original, final Connection connection,
			final BindParameterMapperManager parameterMapperManager) {
		return original.toString();
	}
226570
@Override
	public Object toJdbc(final Date original, final Connection connection,
			final BindParameterMapperManager parameterMapperManager) {
		if (original instanceof java.sql.Date || original instanceof java.sql.Timestamp
				|| original instanceof java.sql.Time) {
			return original;
		}
		return new java.sql.Timestamp(original.getTime());
	}
76509
private void convertValue() throws JspException {

        if ((type == null) || (type.equalsIgnoreCase(TIMESTAMP_TYPE))) {
            if (!(value instanceof java.sql.Timestamp)) {
                value = new java.sql.Timestamp(value.getTime());
            }
        } else if (type.equalsIgnoreCase(TIME_TYPE)) {
            if (!(value instanceof java.sql.Time)) {
                value = new java.sql.Time(value.getTime());
            }
        } else if (type.equalsIgnoreCase(DATE_TYPE)) {
            if (!(value instanceof java.sql.Date)) {
                value = new java.sql.Date(value.getTime());
            }
        } else {
            throw new JspException(
                    Resources.getMessage("SQL_DATE_PARAM_INVALID_TYPE", type));
        }
    }
339013
function columnToSQL(col) {
	var sql = "`" + col.name + "` ";

	sql += nrutil.typeToSQL(col.type);

	if (col['additional']) {
		sql += ' ' + col['additional'];
	}

	if (!col['allow_null']) {
		sql += " NOT NULL";
	}

	if (col['default_value'] !== undefined) {
		var def = col['default_value']

		sql += " DEFAULT " + nrutil.serialize(def);
	}

	if (col.type == 'primary_key') {
		sql += " PRIMARY KEY AUTO_INCREMENT";
	}

	return sql;
}
20321
public QueryBuilder<T, ID> queryBuilder() throws SQLException {
		if (statementBuilder instanceof QueryBuilder) {
			return (QueryBuilder<T, ID>) statementBuilder;
		} else {
			throw new SQLException("Cannot cast " + statementBuilder.getType() + " to QueryBuilder");
		}
	}
541090
@Override
    public int getSqlType(String paramName) {
        if (!hasValue(paramName)) {
            return TYPE_UNKNOWN;
        }
        Object value = getValue(paramName);
        return StatementCreatorUtils.javaTypeToSqlParameterType(value.getClass());
    }
870520
public <T> T  sqlObject(Class<T> beanType,  String entity ) throws ElasticSearchException {
		SQLRestResponse result = this.client.executeRequest("/_xpack/sql",entity,   new SQLRestResponseHandler());
		return ResultUtil.buildSQLObject(result,beanType);
	}
858038
public Object convertJavaFieldToSqlArgValue(Object fieldVal) throws SQLException {
		/*
		 * Limitation here. Some people may want to override the null with their own value in the converter but we
		 * currently don't allow that. Specifying a default value I guess is a better mechanism.
		 */
		if (fieldVal == null) {
			return null;
		} else {
			return fieldConverter.javaToSqlArg(this, fieldVal);
		}
	}
1156441
public String toSQL(final MasterSlaveRule masterSlaveRule, final ShardingDataSourceMetaData shardingDataSourceMetaData) {
        StringBuilder result = new StringBuilder();
        for (Object each : segments) {
            if (each instanceof SchemaPlaceholder) {
                result.append(shardingDataSourceMetaData.getActualDataSourceMetaData(masterSlaveRule.getMasterDataSourceName()).getSchemaName());
            } else {
                result.append(each);
            }
        }
        return result.toString();
    }
17738
public Object sqlToJava(Object source) throws ConversionException
    {
        if (source == null)
        {
            return null;
        }
        if (source.toString().equals(NULLVALUE))
        {
            return null;
        }
        if (source.toString().equals(EMPTYCOLLEC))
        {
            return new ArrayList();
        }
        List v = new ArrayList();
        StringBuffer input = new StringBuffer();
        StringBuffer newString = new StringBuffer();
        int pos = 0;
        int length;

        input.append(source.toString());
        length = input.length();
        while (pos < length)
        {
            if (input.charAt(pos) != '#')
            {
                newString.append(input.charAt(pos));
            }
            else
            {
                if (input.charAt(pos + 1) != '#')
                {
                    v.add(newString.toString());
                    newString = new StringBuffer();
                }
                else
                {
                    newString.append('#');
                    ++pos;
                }
            }
            ++pos;
        }
        v.add(newString.toString());
        return v;
    }
1176431
public Object sqlToJava(Object source)
    {
        if(source == null)
            return null;
        try
        {
            return SerializationUtils.deserialize((byte[]) source);
        }
        catch(Throwable t)
        {
            throw new ConversionException(t);
        }
    }
439657
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {

        String[] columns;
        try
        {
            columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
        }
        catch (QueryException e)
        {
            columns = new String[0];
        }

        // if there are columns that map the given property.. the property exists, so we don't need to add anything to the sql
        return columns.length > 0 ? "FALSE" : "TRUE";
    }
304876
public static java.sql.Timestamp toSqlTimestamp(java.util.Date date) {
		return new java.sql.Timestamp(date.getTime());
	}
827989
function columnsToSQL(columns) {
    return columns
        .map(column => {
            let str = exprToSQL(column.expr);

            if (column.as !== null) {
                str += ' AS ';
                if (column.as.match(/^[a-z_][0-9a-z_]*$/i)) str += identifierToSql(column.as);
                else str += '"' + column.as + '"';
            }

            return str;
        })
        .join(', ');
}
274784
private static void insertWithQueryBuilder(CqlSession session) {
    // Simple statement:
    Statement stmt =
        insertInto("examples", "querybuilder_json")
            .json("{ \"id\": 1, \"name\": \"Mouse\", \"specs\": { \"color\": \"silver\" } }")
            .build();
    session.execute(stmt);

    // Prepare and bind:
    PreparedStatement pst =
        session.prepare(
            insertInto("examples", "querybuilder_json").json(bindMarker("payload")).build());
    session.execute(
        pst.bind()
            .setString(
                "payload",
                "{ \"id\": 2, \"name\": \"Keyboard\", \"specs\": { \"layout\": \"qwerty\" } }"));

    // fromJson on a single column:
    stmt =
        insertInto("examples", "querybuilder_json")
            .value("id", literal(3))
            .value("name", literal("Screen"))
            .value("specs", function("fromJson", literal("{ \"size\": \"24-inch\" }")))
            .build();
    session.execute(stmt);
  }