[#1899] Make some JDBC-related utility methods publicly available
in org.jooq.tools.jdbc.JDBCUtils - Renamed internal Util class to Utils, to be consistent with other utility classes
This commit is contained in:
parent
2b38a75c54
commit
73955ed6ea
@ -139,7 +139,7 @@ abstract class AbstractBindContext extends AbstractContext<BindContext> implemen
|
||||
return bindValue0(value, type);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw Util.translate(null, e);
|
||||
throw Utils.translate(null, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -489,26 +489,26 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
|
||||
@Override
|
||||
public final Condition startsWith(T value) {
|
||||
Field<String> concat = Factory.concat(Util.escapeForLike(value), inline("%"));
|
||||
return like(concat, Util.ESCAPE);
|
||||
Field<String> concat = Factory.concat(Utils.escapeForLike(value), inline("%"));
|
||||
return like(concat, Utils.ESCAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition startsWith(Field<T> value) {
|
||||
Field<String> concat = Factory.concat(Util.escapeForLike(value), inline("%"));
|
||||
return like(concat, Util.ESCAPE);
|
||||
Field<String> concat = Factory.concat(Utils.escapeForLike(value), inline("%"));
|
||||
return like(concat, Utils.ESCAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition endsWith(T value) {
|
||||
Field<String> concat = Factory.concat(inline("%"), Util.escapeForLike(value));
|
||||
return like(concat, Util.ESCAPE);
|
||||
Field<String> concat = Factory.concat(inline("%"), Utils.escapeForLike(value));
|
||||
return like(concat, Utils.ESCAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Condition endsWith(Field<T> value) {
|
||||
Field<String> concat = Factory.concat(inline("%"), Util.escapeForLike(value));
|
||||
return like(concat, Util.ESCAPE);
|
||||
Field<String> concat = Factory.concat(inline("%"), Utils.escapeForLike(value));
|
||||
return like(concat, Utils.ESCAPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1563,13 +1563,13 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Field<String> concat(Field<?>... fields) {
|
||||
return Factory.concat(Util.combine(this, fields));
|
||||
return Factory.concat(Utils.combine(this, fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Field<String> concat(String... values) {
|
||||
return Factory.concat(Util.combine(this, vals((Object[]) values).toArray(new Field[0])));
|
||||
return Factory.concat(Utils.combine(this, vals((Object[]) values).toArray(new Field[0])));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1713,12 +1713,12 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Field<T> coalesce(T option, T... options) {
|
||||
return Factory.coalesce(this, Util.combine(val(option), vals(options).toArray(new Field[0])));
|
||||
return Factory.coalesce(this, Utils.combine(val(option), vals(options).toArray(new Field[0])));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final Field<T> coalesce(Field<T> option, Field<?>... options) {
|
||||
return Factory.coalesce(this, Util.combine(option, options));
|
||||
return Factory.coalesce(this, Utils.combine(option, options));
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
statement = null;
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw Util.translate(sql, e);
|
||||
throw Utils.translate(sql, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
statement.cancel();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw Util.translate(sql, e);
|
||||
throw Utils.translate(sql, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,7 +263,7 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
|
||||
// ResultQuery.fetchLazy() needs to keep open resources
|
||||
if (!keepResult()) {
|
||||
Util.safeClose(listener, ctx, keepStatement());
|
||||
Utils.safeClose(listener, ctx, keepStatement());
|
||||
}
|
||||
|
||||
if (!keepStatement()) {
|
||||
|
||||
@ -214,6 +214,6 @@ abstract class AbstractQueryPart implements QueryPartInternal {
|
||||
* Internal convenience method
|
||||
*/
|
||||
protected final DataAccessException translate(String sql, SQLException e) {
|
||||
return Util.translate(sql, e);
|
||||
return Utils.translate(sql, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,14 +36,14 @@
|
||||
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Util.getAnnotatedGetter;
|
||||
import static org.jooq.impl.Util.getAnnotatedMembers;
|
||||
import static org.jooq.impl.Util.getAnnotatedSetters;
|
||||
import static org.jooq.impl.Util.getMatchingGetter;
|
||||
import static org.jooq.impl.Util.getMatchingMembers;
|
||||
import static org.jooq.impl.Util.getMatchingSetters;
|
||||
import static org.jooq.impl.Util.getPropertyName;
|
||||
import static org.jooq.impl.Util.hasColumnAnnotations;
|
||||
import static org.jooq.impl.Utils.getAnnotatedGetter;
|
||||
import static org.jooq.impl.Utils.getAnnotatedMembers;
|
||||
import static org.jooq.impl.Utils.getAnnotatedSetters;
|
||||
import static org.jooq.impl.Utils.getMatchingGetter;
|
||||
import static org.jooq.impl.Utils.getMatchingMembers;
|
||||
import static org.jooq.impl.Utils.getMatchingSetters;
|
||||
import static org.jooq.impl.Utils.getPropertyName;
|
||||
import static org.jooq.impl.Utils.hasColumnAnnotations;
|
||||
import static org.jooq.tools.reflect.Reflect.accessible;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
@ -322,7 +322,7 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
*/
|
||||
@Override
|
||||
public Record original() {
|
||||
AbstractRecord result = Util.newRecord(getClass(), getFieldProvider(), getConfiguration());
|
||||
AbstractRecord result = Utils.newRecord(getClass(), getFieldProvider(), getConfiguration());
|
||||
Value<?>[] v = getValues();
|
||||
|
||||
for (int i = 0; i < v.length; i++) {
|
||||
@ -507,7 +507,7 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
|
||||
// Match the first constructor by parameter length
|
||||
if (parameterTypes.length == getFields().size()) {
|
||||
Object[] converted = Util.convert(parameterTypes, intoArray());
|
||||
Object[] converted = Utils.convert(parameterTypes, intoArray());
|
||||
return accessible(constructor).newInstance(converted);
|
||||
}
|
||||
}
|
||||
@ -560,7 +560,7 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
}
|
||||
}
|
||||
|
||||
Object[] converted = Util.convert(parameterTypes, parameterValues);
|
||||
Object[] converted = Utils.convert(parameterTypes, parameterValues);
|
||||
return accessible(constructor).newInstance(converted);
|
||||
}
|
||||
|
||||
@ -606,13 +606,13 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
@Override
|
||||
public final <R extends Record> R into(Table<R> table) {
|
||||
try {
|
||||
R result = Util.newRecord(table, getConfiguration());
|
||||
R result = Utils.newRecord(table, getConfiguration());
|
||||
|
||||
for (Field<?> targetField : table.getFields()) {
|
||||
Field<?> sourceField = getField(targetField);
|
||||
|
||||
if (sourceField != null) {
|
||||
Util.setValue(result, targetField, this, sourceField);
|
||||
Utils.setValue(result, targetField, this, sourceField);
|
||||
}
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
|
||||
// Use only the first applicable method or member
|
||||
if (method != null) {
|
||||
Util.setValue(this, field, method.invoke(source));
|
||||
Utils.setValue(this, field, method.invoke(source));
|
||||
}
|
||||
else if (members.size() > 0) {
|
||||
from(source, members.get(0), field);
|
||||
@ -699,7 +699,7 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
Field<?> sourceField = source.getField(field);
|
||||
|
||||
if (sourceField != null) {
|
||||
Util.setValue(this, field, source, sourceField);
|
||||
Utils.setValue(this, field, source, sourceField);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -745,32 +745,32 @@ abstract class AbstractRecord extends AbstractStore<Object> implements Record {
|
||||
|
||||
if (mType.isPrimitive()) {
|
||||
if (mType == byte.class) {
|
||||
Util.setValue(this, field, member.getByte(source));
|
||||
Utils.setValue(this, field, member.getByte(source));
|
||||
}
|
||||
else if (mType == short.class) {
|
||||
Util.setValue(this, field, member.getShort(source));
|
||||
Utils.setValue(this, field, member.getShort(source));
|
||||
}
|
||||
else if (mType == int.class) {
|
||||
Util.setValue(this, field, member.getInt(source));
|
||||
Utils.setValue(this, field, member.getInt(source));
|
||||
}
|
||||
else if (mType == long.class) {
|
||||
Util.setValue(this, field, member.getLong(source));
|
||||
Utils.setValue(this, field, member.getLong(source));
|
||||
}
|
||||
else if (mType == float.class) {
|
||||
Util.setValue(this, field, member.getFloat(source));
|
||||
Utils.setValue(this, field, member.getFloat(source));
|
||||
}
|
||||
else if (mType == double.class) {
|
||||
Util.setValue(this, field, member.getDouble(source));
|
||||
Utils.setValue(this, field, member.getDouble(source));
|
||||
}
|
||||
else if (mType == boolean.class) {
|
||||
Util.setValue(this, field, member.getBoolean(source));
|
||||
Utils.setValue(this, field, member.getBoolean(source));
|
||||
}
|
||||
else if (mType == char.class) {
|
||||
Util.setValue(this, field, member.getChar(source));
|
||||
Utils.setValue(this, field, member.getChar(source));
|
||||
}
|
||||
}
|
||||
else {
|
||||
Util.setValue(this, field, member.get(source));
|
||||
Utils.setValue(this, field, member.get(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
throw ctx.exception();
|
||||
}
|
||||
finally {
|
||||
Util.safeClose(listener, ctx);
|
||||
Utils.safeClose(listener, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,7 +466,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
}
|
||||
|
||||
private final void toSQLQualifiedName(RenderContext context) {
|
||||
Schema mappedSchema = Util.getMappedSchema(context, getSchema());
|
||||
Schema mappedSchema = Utils.getMappedSchema(context, getSchema());
|
||||
|
||||
if (context.qualify()) {
|
||||
if (mappedSchema != null) {
|
||||
@ -512,12 +512,12 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
// also the type name
|
||||
case ORACLE: {
|
||||
if (sqlType == Types.STRUCT) {
|
||||
UDTRecord<?> record = Util.newRecord((Class<? extends UDTRecord<?>>) parameter.getType());
|
||||
UDTRecord<?> record = Utils.newRecord((Class<? extends UDTRecord<?>>) parameter.getType());
|
||||
statement.registerOutParameter(index, Types.STRUCT, record.getSQLTypeName());
|
||||
}
|
||||
|
||||
else if (sqlType == Types.ARRAY) {
|
||||
ArrayRecord<?> record = Util.newArrayRecord(
|
||||
ArrayRecord<?> record = Utils.newArrayRecord(
|
||||
(Class<? extends ArrayRecord<?>>) parameter.getType(), c);
|
||||
statement.registerOutParameter(index, Types.ARRAY, record.getName());
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ abstract class AbstractSelect<R extends Record> extends AbstractResultQuery<R> i
|
||||
public final Table<R> asTable() {
|
||||
// Its usually better to alias nested selects that are used in
|
||||
// the FROM clause of a query
|
||||
return new SelectQueryAsTable<R>(this).as("alias_" + Util.hash(this));
|
||||
return new SelectQueryAsTable<R>(this).as("alias_" + Utils.hash(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -110,7 +110,7 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
|
||||
}
|
||||
else {
|
||||
try {
|
||||
A record = Util.newArrayRecord(field.getType(), getConfiguration());
|
||||
A record = Utils.newArrayRecord(field.getType(), getConfiguration());
|
||||
record.setList(value);
|
||||
addValue(field, record);
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ implements
|
||||
|
||||
if (!forUpdateOf.isEmpty()) {
|
||||
context.keyword(" of ");
|
||||
Util.fieldNames(context, forUpdateOf);
|
||||
Utils.fieldNames(context, forUpdateOf);
|
||||
}
|
||||
else if (!forUpdateOfTables.isEmpty()) {
|
||||
context.keyword(" of ");
|
||||
@ -270,7 +270,7 @@ implements
|
||||
|
||||
// Render the OF [table-names] clause
|
||||
default:
|
||||
Util.tableNames(context, forUpdateOfTables);
|
||||
Utils.tableNames(context, forUpdateOfTables);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -320,8 +320,8 @@ implements
|
||||
toSQLReference0(local);
|
||||
String enclosed = local.render();
|
||||
|
||||
String subqueryName = "limit_" + Util.hash(enclosed);
|
||||
String rownumName = "rownum_" + Util.hash(enclosed);
|
||||
String subqueryName = "limit_" + Utils.hash(enclosed);
|
||||
String rownumName = "rownum_" + Utils.hash(enclosed);
|
||||
|
||||
context.keyword("select * from (")
|
||||
.formatIndentStart()
|
||||
@ -384,8 +384,8 @@ implements
|
||||
toSQLReference0(local);
|
||||
String enclosed = local.render();
|
||||
|
||||
String subqueryName = "limit_" + Util.hash(enclosed);
|
||||
String rownumName = "rownum_" + Util.hash(enclosed);
|
||||
String subqueryName = "limit_" + Utils.hash(enclosed);
|
||||
String rownumName = "rownum_" + Utils.hash(enclosed);
|
||||
|
||||
context.keyword("select * from (")
|
||||
.formatIndentStart()
|
||||
|
||||
@ -110,7 +110,7 @@ class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
ArrayTable table = (ArrayTable) o;
|
||||
|
||||
context.sql("(");
|
||||
Util.fieldNames(context, table.getFields());
|
||||
Utils.fieldNames(context, table.getFields());
|
||||
context.sql(")");
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ class ArrayTable extends AbstractTable<Record> {
|
||||
// VARRAY / TABLE types returned from functions
|
||||
else if (ArrayRecord.class.isAssignableFrom(array.getDataType().getType())) {
|
||||
// TODO [#523] This information should be available in ARRAY meta-data
|
||||
ArrayRecord<?> dummy = Util.newArrayRecord((Class<ArrayRecord<?>>) array.getDataType().getType(), DefaultConfiguration.DEFAULT_CONFIGURATION);
|
||||
ArrayRecord<?> dummy = Utils.newArrayRecord((Class<ArrayRecord<?>>) array.getDataType().getType(), DefaultConfiguration.DEFAULT_CONFIGURATION);
|
||||
arrayType = dummy.getDataType().getType();
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ class BatchMultiple implements Batch {
|
||||
throw ctx.exception();
|
||||
}
|
||||
finally {
|
||||
Util.safeClose(listener, ctx);
|
||||
Utils.safeClose(listener, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ class BatchSingle implements BatchBindStep {
|
||||
throw ctx.exception();
|
||||
}
|
||||
finally {
|
||||
Util.safeClose(listener, ctx);
|
||||
Utils.safeClose(listener, ctx);
|
||||
|
||||
// Restore bind variables to values prior to batch execution
|
||||
for (int i = 0; i < params.size(); i++) {
|
||||
|
||||
@ -94,13 +94,13 @@ class Contains<T> extends AbstractCondition {
|
||||
Field<String> concat;
|
||||
|
||||
if (rhs == null) {
|
||||
concat = Factory.concat(inline("%"), Util.escapeForLike(value), inline("%"));
|
||||
concat = Factory.concat(inline("%"), Utils.escapeForLike(value), inline("%"));
|
||||
}
|
||||
else {
|
||||
concat = Factory.concat(inline("%"), Util.escapeForLike(rhs), inline("%"));
|
||||
concat = Factory.concat(inline("%"), Utils.escapeForLike(rhs), inline("%"));
|
||||
}
|
||||
|
||||
return lhs.like(concat, Util.ESCAPE);
|
||||
return lhs.like(concat, Utils.ESCAPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1261,7 +1261,7 @@ class CursorImpl<R extends Record> implements Cursor<R> {
|
||||
rs.updateRow();
|
||||
}
|
||||
|
||||
record = Util.newRecord(type, fields, ctx.configuration());
|
||||
record = Utils.newRecord(type, fields, ctx.configuration());
|
||||
|
||||
ctx.record(record);
|
||||
listener.recordStart(ctx);
|
||||
|
||||
@ -57,7 +57,7 @@ class Decode<T, Z> extends AbstractFunction<Z> {
|
||||
private final Field<?>[] more;
|
||||
|
||||
public Decode(Field<T> field, Field<T> search, Field<Z> result, Field<?>[] more) {
|
||||
super("decode", result.getDataType(), Util.combine(field, search, result, more));
|
||||
super("decode", result.getDataType(), Utils.combine(field, search, result, more));
|
||||
|
||||
this.field = field;
|
||||
this.search = search;
|
||||
|
||||
@ -40,7 +40,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.SQLDialect.SQLSERVER;
|
||||
import static org.jooq.SQLDialect.SYBASE;
|
||||
import static org.jooq.impl.Util.getDriverConnection;
|
||||
import static org.jooq.impl.Utils.getDriverConnection;
|
||||
import static org.jooq.tools.reflect.Reflect.on;
|
||||
import static org.jooq.util.postgres.PostgresUtils.toPGArrayString;
|
||||
import static org.jooq.util.postgres.PostgresUtils.toPGInterval;
|
||||
@ -131,13 +131,13 @@ class DefaultBindContext extends AbstractBindContext {
|
||||
|
||||
// Oracle-style ARRAY types need to be bound with their type name
|
||||
if (ArrayRecord.class.isAssignableFrom(type)) {
|
||||
String typeName = Util.newArrayRecord((Class<ArrayRecord<?>>) type, configuration).getName();
|
||||
String typeName = Utils.newArrayRecord((Class<ArrayRecord<?>>) type, configuration).getName();
|
||||
stmt.setNull(nextIndex(), sqlType, typeName);
|
||||
}
|
||||
|
||||
// [#1126] Oracle's UDTs need to be bound with their type name
|
||||
else if (UDTRecord.class.isAssignableFrom(type)) {
|
||||
String typeName = Util.newRecord((Class<UDTRecord<?>>) type).getUDT().getName();
|
||||
String typeName = Utils.newRecord((Class<UDTRecord<?>>) type).getUDT().getName();
|
||||
stmt.setNull(nextIndex(), sqlType, typeName);
|
||||
}
|
||||
|
||||
|
||||
@ -405,6 +405,6 @@ class DefaultExecuteContext extends AbstractConfiguration implements ExecuteCont
|
||||
@Override
|
||||
public final void sqlException(SQLException e) {
|
||||
this.sqlException = e;
|
||||
exception(Util.translate(sql(), e));
|
||||
exception(Utils.translate(sql(), e));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class ExecuteListeners implements ExecuteListener {
|
||||
private boolean fetchEnd;
|
||||
|
||||
ExecuteListeners(ExecuteContext ctx) {
|
||||
listeners = Util.getListeners(ctx);
|
||||
listeners = Utils.getListeners(ctx);
|
||||
|
||||
start(ctx);
|
||||
}
|
||||
|
||||
@ -1031,7 +1031,7 @@ public class Executor implements FactoryOperations {
|
||||
Record record = new RecordImpl(fields);
|
||||
|
||||
for (int i = 0; i < Math.min(values.length, fields.size()); i++) {
|
||||
Util.setValue(record, fields.get(i), values[i]);
|
||||
Utils.setValue(record, fields.get(i), values[i]);
|
||||
}
|
||||
|
||||
result.add(record);
|
||||
@ -1402,7 +1402,7 @@ public class Executor implements FactoryOperations {
|
||||
*/
|
||||
@Override
|
||||
public final <R extends UDTRecord<R>> R newRecord(UDT<R> type) {
|
||||
return Util.newRecord(type, this);
|
||||
return Utils.newRecord(type, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1410,7 +1410,7 @@ public class Executor implements FactoryOperations {
|
||||
*/
|
||||
@Override
|
||||
public final <R extends TableRecord<R>> R newRecord(Table<R> table) {
|
||||
return Util.newRecord(table, this);
|
||||
return Utils.newRecord(table, this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1482,7 +1482,7 @@ public class Executor implements FactoryOperations {
|
||||
@Override
|
||||
public final <R extends UpdatableRecord<R>> int executeUpdate(R record) {
|
||||
UpdateQuery<R> update = updateQuery(record.getTable());
|
||||
Util.addConditions(update, record, record.getTable().getMainKey().getFieldsArray());
|
||||
Utils.addConditions(update, record, record.getTable().getMainKey().getFieldsArray());
|
||||
update.setRecord(record);
|
||||
return update.execute();
|
||||
}
|
||||
@ -1504,7 +1504,7 @@ public class Executor implements FactoryOperations {
|
||||
@Override
|
||||
public final <R extends UpdatableRecord<R>> int executeDelete(R record) {
|
||||
DeleteQuery<R> delete = deleteQuery(record.getTable());
|
||||
Util.addConditions(delete, record, record.getTable().getMainKey().getFieldsArray());
|
||||
Utils.addConditions(delete, record, record.getTable().getMainKey().getFieldsArray());
|
||||
return delete.execute();
|
||||
}
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ class Expression<T> extends AbstractFunction<T> {
|
||||
private final ExpressionOperator operator;
|
||||
|
||||
Expression(ExpressionOperator operator, Field<T> lhs, Field<?>... rhs) {
|
||||
super(operator.toSQL(), lhs.getDataType(), Util.combine(lhs, rhs));
|
||||
super(operator.toSQL(), lhs.getDataType(), Utils.combine(lhs, rhs));
|
||||
|
||||
this.operator = operator;
|
||||
this.lhs = lhs;
|
||||
|
||||
@ -50,7 +50,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.SQLDialect.SQLSERVER;
|
||||
import static org.jooq.SQLDialect.SYBASE;
|
||||
import static org.jooq.impl.Term.ROW_NUMBER;
|
||||
import static org.jooq.impl.Util.combine;
|
||||
import static org.jooq.impl.Utils.combine;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
|
||||
@ -39,7 +39,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.impl.Executor.getNewFactory;
|
||||
import static org.jooq.impl.Util.getDriverConnection;
|
||||
import static org.jooq.impl.Utils.getDriverConnection;
|
||||
import static org.jooq.tools.reflect.Reflect.on;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -524,7 +524,7 @@ public final class FieldTypeHelper {
|
||||
}
|
||||
else {
|
||||
// TODO: [#523] Use array record meta data instead
|
||||
ArrayRecord<?> record = Util.newArrayRecord(type, configuration);
|
||||
ArrayRecord<?> record = Utils.newArrayRecord(type, configuration);
|
||||
record.set(array);
|
||||
return record;
|
||||
}
|
||||
@ -1041,7 +1041,7 @@ public final class FieldTypeHelper {
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
UDTRecord<?> record = (UDTRecord<?>) Util.newRecord((Class) type);
|
||||
UDTRecord<?> record = (UDTRecord<?>) Utils.newRecord((Class) type);
|
||||
List<String> values = PostgresUtils.toPGObject(object.toString());
|
||||
|
||||
List<Field<?>> fields = record.getFields();
|
||||
|
||||
@ -606,7 +606,7 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
|
||||
// additional query
|
||||
if (returning.size() == 1 && returning.get(0).equals(field)) {
|
||||
for (Number id : ids) {
|
||||
R typed = Util.newRecord(into, configuration);
|
||||
R typed = Utils.newRecord(into, configuration);
|
||||
((AbstractRecord) typed).setValue(field, new Value<Number>(id));
|
||||
getReturnedRecords().add(typed);
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep, Ta
|
||||
else {
|
||||
context.formatSeparator()
|
||||
.keyword("using (");
|
||||
Util.fieldNames(context, using);
|
||||
Utils.fieldNames(context, using);
|
||||
context.sql(")");
|
||||
}
|
||||
}
|
||||
@ -304,7 +304,7 @@ class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep, Ta
|
||||
|
||||
@Override
|
||||
public final TableOnStep partitionBy(Field<?>... fields) {
|
||||
return partitionBy(Util.list(fields));
|
||||
return partitionBy(Utils.list(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -450,7 +450,7 @@ class LoaderImpl<R extends TableRecord<R>> implements
|
||||
// SQLExceptions originating from rollbacks or commits are always fatal
|
||||
// They are propagated, and not swallowed
|
||||
catch (SQLException e) {
|
||||
throw Util.translate(null, e);
|
||||
throw Utils.translate(null, e);
|
||||
}
|
||||
finally {
|
||||
reader.close();
|
||||
|
||||
@ -42,7 +42,7 @@ import static org.jooq.impl.Factory.notExists;
|
||||
import static org.jooq.impl.Factory.nullSafe;
|
||||
import static org.jooq.impl.Factory.val;
|
||||
import static org.jooq.impl.Factory.vals;
|
||||
import static org.jooq.impl.Util.convert;
|
||||
import static org.jooq.impl.Utils.convert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -548,12 +548,12 @@ implements
|
||||
.formatSeparator();
|
||||
|
||||
context.sql("(");
|
||||
Util.fieldNames(context, getH2Fields());
|
||||
Utils.fieldNames(context, getH2Fields());
|
||||
context.sql(")");
|
||||
|
||||
if (!getH2Keys().isEmpty()) {
|
||||
context.keyword(" key (");
|
||||
Util.fieldNames(context, getH2Keys());
|
||||
Utils.fieldNames(context, getH2Keys());
|
||||
context.sql(")");
|
||||
}
|
||||
|
||||
@ -576,7 +576,7 @@ implements
|
||||
.keyword("using ")
|
||||
.formatIndentStart()
|
||||
.formatNewLine()
|
||||
.sql(Util.wrapInParentheses(context.render(using)))
|
||||
.sql(Utils.wrapInParentheses(context.render(using)))
|
||||
.formatIndentEnd()
|
||||
.declareTables(false);
|
||||
|
||||
@ -584,7 +584,7 @@ implements
|
||||
case SQLSERVER:
|
||||
case SYBASE: {
|
||||
if (using instanceof Select) {
|
||||
int hash = Util.hash(using);
|
||||
int hash = Utils.hash(using);
|
||||
|
||||
context.keyword(" as ")
|
||||
.sql("dummy_")
|
||||
@ -597,7 +597,7 @@ implements
|
||||
// Some fields are unnamed
|
||||
// [#579] Correct this
|
||||
String name = StringUtils.isBlank(field.getName())
|
||||
? "dummy_" + hash + "_" + Util.hash(field)
|
||||
? "dummy_" + hash + "_" + Utils.hash(field)
|
||||
: field.getName();
|
||||
|
||||
context.sql(separator).literal(name);
|
||||
@ -613,7 +613,7 @@ implements
|
||||
|
||||
context.formatSeparator()
|
||||
.keyword("on ")
|
||||
.sql(Util.wrapInParentheses(context.render(on)));
|
||||
.sql(Utils.wrapInParentheses(context.render(on)));
|
||||
|
||||
// [#999] WHEN MATCHED clause is optional
|
||||
if (matchedUpdate != null) {
|
||||
|
||||
@ -117,7 +117,7 @@ class MetaDataFieldProvider implements FieldProvider, Serializable {
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw Util.translate(null, e);
|
||||
throw Utils.translate(null, e);
|
||||
}
|
||||
|
||||
meta = null;
|
||||
|
||||
@ -763,7 +763,7 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
Record key = new RecordImpl(keyList);
|
||||
|
||||
for (Field<?> field : keys) {
|
||||
Util.setValue(key, field, record, field);
|
||||
Utils.setValue(key, field, record, field);
|
||||
}
|
||||
|
||||
if (map.put(key, record) != null) {
|
||||
@ -869,7 +869,7 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
Record key = new RecordImpl(keyList);
|
||||
|
||||
for (Field<?> field : keys) {
|
||||
Util.setValue(key, field, record, field);
|
||||
Utils.setValue(key, field, record, field);
|
||||
}
|
||||
|
||||
Result<R> result = map.get(key);
|
||||
@ -918,7 +918,7 @@ class ResultImpl<R extends Record> implements Result<R>, AttachableInternal {
|
||||
Record key = new RecordImpl(keyList);
|
||||
|
||||
for (Field<?> field : keys) {
|
||||
Util.setValue(key, field, record, field);
|
||||
Utils.setValue(key, field, record, field);
|
||||
}
|
||||
|
||||
List<E> list = map.get(key);
|
||||
|
||||
@ -1239,7 +1239,7 @@ class ResultSetImpl extends JDBC41ResultSet implements ResultSet, Serializable {
|
||||
Schema mapped = null;
|
||||
|
||||
if (configuration != null) {
|
||||
mapped = Util.getMappedSchema(configuration, schema);
|
||||
mapped = Utils.getMappedSchema(configuration, schema);
|
||||
}
|
||||
|
||||
if (mapped != null) {
|
||||
|
||||
@ -53,7 +53,7 @@ class SQLCondition extends AbstractCondition {
|
||||
|
||||
SQLCondition(String sql, Object[] substitutes) {
|
||||
this.sql = sql;
|
||||
this.substitutes = Util.queryParts(substitutes);
|
||||
this.substitutes = Utils.queryParts(substitutes);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -66,12 +66,12 @@ class SQLCondition extends AbstractCondition {
|
||||
// in parentheses to ensure correct semantics
|
||||
|
||||
context.sql("(");
|
||||
Util.renderAndBind(context, null, sql, substitutes);
|
||||
Utils.renderAndBind(context, null, sql, substitutes);
|
||||
context.sql(")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
Util.renderAndBind(null, context, sql, substitutes);
|
||||
Utils.renderAndBind(null, context, sql, substitutes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class SQLField<T> extends AbstractField<T> {
|
||||
super(sql, type);
|
||||
|
||||
this.sql = sql;
|
||||
this.substitutes = Util.queryParts(substitutes);
|
||||
this.substitutes = Utils.queryParts(substitutes);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -65,12 +65,12 @@ class SQLField<T> extends AbstractField<T> {
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
Util.renderAndBind(context, null, sql, substitutes);
|
||||
Utils.renderAndBind(context, null, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
Util.renderAndBind(null, context, sql, substitutes);
|
||||
Utils.renderAndBind(null, context, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -59,7 +59,7 @@ class SQLQuery extends AbstractQuery {
|
||||
super(configuration);
|
||||
|
||||
this.sql = sql;
|
||||
this.substitutes = Util.queryParts(substitutes);
|
||||
this.substitutes = Utils.queryParts(substitutes);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -68,11 +68,11 @@ class SQLQuery extends AbstractQuery {
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
Util.renderAndBind(context, null, sql, substitutes);
|
||||
Utils.renderAndBind(context, null, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
Util.renderAndBind(null, context, sql, substitutes);
|
||||
Utils.renderAndBind(null, context, sql, substitutes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class SQLResultQuery extends AbstractResultQuery<Record> {
|
||||
super(configuration);
|
||||
|
||||
this.sql = sql;
|
||||
this.substitutes = Util.queryParts(substitutes);
|
||||
this.substitutes = Utils.queryParts(substitutes);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -73,12 +73,12 @@ class SQLResultQuery extends AbstractResultQuery<Record> {
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
Util.renderAndBind(context, null, sql, substitutes);
|
||||
Utils.renderAndBind(context, null, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
Util.renderAndBind(null, context, sql, substitutes);
|
||||
Utils.renderAndBind(null, context, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -57,7 +57,7 @@ class SQLTable extends AbstractTable<Record> {
|
||||
super("sql");
|
||||
|
||||
this.sql = sql;
|
||||
this.substitutes = Util.queryParts(substitutes);
|
||||
this.substitutes = Utils.queryParts(substitutes);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -76,12 +76,12 @@ class SQLTable extends AbstractTable<Record> {
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
Util.renderAndBind(context, null, sql, substitutes);
|
||||
Utils.renderAndBind(context, null, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void bind(BindContext context) {
|
||||
Util.renderAndBind(null, context, sql, substitutes);
|
||||
Utils.renderAndBind(null, context, sql, substitutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -173,7 +173,7 @@ public class SequenceImpl<T extends Number> implements Sequence<T> {
|
||||
|
||||
private final String getQualifiedName(Configuration configuration) {
|
||||
RenderContext local = create(configuration).renderContext();
|
||||
Schema mappedSchema = Util.getMappedSchema(configuration, schema);
|
||||
Schema mappedSchema = Utils.getMappedSchema(configuration, schema);
|
||||
|
||||
if (mappedSchema != null && configuration.getDialect() != CUBRID) {
|
||||
local.sql(mappedSchema);
|
||||
|
||||
@ -111,7 +111,7 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
|
||||
}
|
||||
else {
|
||||
if (context.qualify()) {
|
||||
Schema mappedSchema = Util.getMappedSchema(context, getSchema());
|
||||
Schema mappedSchema = Utils.getMappedSchema(context, getSchema());
|
||||
|
||||
if (mappedSchema != null) {
|
||||
context.sql(mappedSchema);
|
||||
@ -119,7 +119,7 @@ public class TableImpl<R extends Record> extends AbstractTable<R> {
|
||||
}
|
||||
}
|
||||
|
||||
context.literal(Util.getMappedTable(context, this).getName());
|
||||
context.literal(Utils.getMappedTable(context, this).getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ import static org.jooq.impl.Factory.field;
|
||||
import static org.jooq.impl.Factory.inline;
|
||||
import static org.jooq.impl.Factory.one;
|
||||
import static org.jooq.impl.Factory.zero;
|
||||
import static org.jooq.impl.Util.extractVal;
|
||||
import static org.jooq.impl.Utils.extractVal;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
|
||||
@ -136,7 +136,7 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractField<R> {
|
||||
// Assume default behaviour if dialect is not available
|
||||
default: {
|
||||
UDT<?> udt = record.getUDT();
|
||||
Schema mappedSchema = Util.getMappedSchema(context, udt.getSchema());
|
||||
Schema mappedSchema = Utils.getMappedSchema(context, udt.getSchema());
|
||||
|
||||
if (mappedSchema != null) {
|
||||
return mappedSchema + "." + udt.getName();
|
||||
|
||||
@ -78,7 +78,7 @@ public class UDTRecordImpl<R extends UDTRecord<R>> extends AbstractRecord implem
|
||||
// case the connected user is not the owner of the UDT
|
||||
Configuration configuration = DefaultExecuteContext.registeredConfiguration();
|
||||
if (configuration != null) {
|
||||
Schema schema = Util.getMappedSchema(configuration, getUDT().getSchema());
|
||||
Schema schema = Utils.getMappedSchema(configuration, getUDT().getSchema());
|
||||
|
||||
if (schema != null) {
|
||||
sb.append(schema.getName());
|
||||
|
||||
@ -173,7 +173,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
private final int storeUpdate(TableField<R, ?>[] keys) {
|
||||
UpdateQuery<R> update = create().updateQuery(getTable());
|
||||
addChangedValues(update);
|
||||
Util.addConditions(update, this, keys);
|
||||
Utils.addConditions(update, this, keys);
|
||||
|
||||
// Don't store records if no value was set by client code
|
||||
if (!update.isExecutable()) return 0;
|
||||
@ -280,7 +280,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
|
||||
try {
|
||||
DeleteQuery<R> delete1 = create().deleteQuery(getTable());
|
||||
Util.addConditions(delete1, this, keys);
|
||||
Utils.addConditions(delete1, this, keys);
|
||||
|
||||
if (isExecuteWithOptimisticLocking()) {
|
||||
|
||||
@ -313,7 +313,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
@Override
|
||||
public final void refresh() {
|
||||
SimpleSelectQuery<R> select = create().selectQuery(getTable());
|
||||
Util.addConditions(select, this, getMainKey().getFieldsArray());
|
||||
Utils.addConditions(select, this, getMainKey().getFieldsArray());
|
||||
|
||||
if (select.execute() == 1) {
|
||||
AbstractRecord record = (AbstractRecord) select.getResult().get(0);
|
||||
@ -379,8 +379,8 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
TableField<R, ?> v = getTable().getRecordVersion();
|
||||
TableField<R, ?> t = getTable().getRecordTimestamp();
|
||||
|
||||
if (v != null) Util.addCondition(query, this, v);
|
||||
if (t != null) Util.addCondition(query, this, t);
|
||||
if (v != null) Utils.addCondition(query, this, v);
|
||||
if (t != null) Utils.addCondition(query, this, t);
|
||||
}
|
||||
|
||||
private final boolean isTimestampOrVersionAvailable() {
|
||||
@ -395,7 +395,7 @@ public class UpdatableRecordImpl<R extends UpdatableRecord<R>> extends TableReco
|
||||
*/
|
||||
private final void checkIfChanged(TableField<R, ?>[] keys) {
|
||||
SimpleSelectQuery<R> select = create().selectQuery(getTable());
|
||||
Util.addConditions(select, this, keys);
|
||||
Utils.addConditions(select, this, keys);
|
||||
|
||||
// [#1547] SQLite doesn't support FOR UPDATE. CUBRID and SQL Server
|
||||
// can simulate it, though!
|
||||
|
||||
@ -88,7 +88,7 @@ import org.jooq.tools.reflect.Reflect;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class Util {
|
||||
final class Utils {
|
||||
|
||||
/**
|
||||
* The default escape character for <code>[a] LIKE [b] ESCAPE [...]</code>
|
||||
@ -356,27 +356,27 @@ class Val<T> extends AbstractField<T> implements Param<T> {
|
||||
|
||||
if (asList(ASE, SQLSERVER, SYBASE).contains(dialect)) {
|
||||
context.sql("0x")
|
||||
.sql(Util.convertBytesToHex(binary));
|
||||
.sql(Utils.convertBytesToHex(binary));
|
||||
}
|
||||
else if (dialect == DB2) {
|
||||
context.keyword("blob")
|
||||
.sql("(X'")
|
||||
.sql(Util.convertBytesToHex(binary))
|
||||
.sql(Utils.convertBytesToHex(binary))
|
||||
.sql("')");
|
||||
}
|
||||
else if (asList(DERBY, H2, HSQLDB, INGRES, MYSQL, SQLITE).contains(dialect)) {
|
||||
context.sql("X'")
|
||||
.sql(Util.convertBytesToHex(binary))
|
||||
.sql(Utils.convertBytesToHex(binary))
|
||||
.sql("'");
|
||||
}
|
||||
else if (asList(ORACLE).contains(dialect)) {
|
||||
context.keyword("hextoraw('")
|
||||
.sql(Util.convertBytesToHex(binary))
|
||||
.sql(Utils.convertBytesToHex(binary))
|
||||
.sql("')");
|
||||
}
|
||||
else if (dialect == POSTGRES) {
|
||||
context.sql("E'")
|
||||
.sql(Util.convertBytesToPostgresOctal(binary))
|
||||
.sql(Utils.convertBytesToPostgresOctal(binary))
|
||||
.keyword("'::bytea");
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ class Val<T> extends AbstractField<T> implements Param<T> {
|
||||
// that do not support inlining binary data
|
||||
else {
|
||||
context.sql("X'")
|
||||
.sql(Util.convertBytesToHex(binary))
|
||||
.sql(Utils.convertBytesToHex(binary))
|
||||
.sql("'");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user