diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractParam.java b/jOOQ/src/main/java/org/jooq/impl/AbstractParam.java index 1d9b4f03f8..1714e5236c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractParam.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractParam.java @@ -41,7 +41,7 @@ import org.jooq.RenderContext; /** * A base implementation for {@link Param} - * + * * @author Lukas Eder */ abstract class AbstractParam extends AbstractField implements Param { @@ -52,7 +52,7 @@ abstract class AbstractParam extends AbstractField implements Param { private static final long serialVersionUID = 1311856649676227970L; private final String paramName; - private T value; + T value; private boolean inline; AbstractParam(T value, DataType type) { diff --git a/jOOQ/src/main/java/org/jooq/impl/UDTConstant.java b/jOOQ/src/main/java/org/jooq/impl/UDTConstant.java index de1ade383a..3558196bba 100644 --- a/jOOQ/src/main/java/org/jooq/impl/UDTConstant.java +++ b/jOOQ/src/main/java/org/jooq/impl/UDTConstant.java @@ -53,12 +53,8 @@ class UDTConstant> extends AbstractParam { private static final long serialVersionUID = 6807729087019209084L; - private final R record; - UDTConstant(R value) { super(value, value.getUDT().getDataType()); - - this.record = value; } @Override @@ -92,11 +88,11 @@ class UDTConstant> extends AbstractParam { context.sql("()"); String separator = ".."; - for (Field field : record.fields()) { + for (Field field : value.fields()) { context.sql(separator); context.sql(field.getName()); context.sql("("); - context.sql(val(record.getValue(field))); + context.sql(val(value.getValue(field))); context.sql(")"); } @@ -115,9 +111,9 @@ class UDTConstant> extends AbstractParam { context.sql("("); String separator = ""; - for (Field field : record.fields()) { + for (Field field : value.fields()) { context.sql(separator); - context.sql(val(record.getValue(field), field)); + context.sql(val(value.getValue(field), field)); separator = ", "; } @@ -135,7 +131,7 @@ class UDTConstant> extends AbstractParam { // Assume default behaviour if dialect is not available default: { - UDT udt = record.getUDT(); + UDT udt = value.getUDT(); Schema mappedSchema = Utils.getMappedSchema(context, udt.getSchema()); if (mappedSchema != null) { @@ -155,7 +151,7 @@ class UDTConstant> extends AbstractParam { // Oracle supports java.sql.SQLData, hence the record can be bound // to the CallableStatement directly case ORACLE: - context.bindValues(record); + context.bindValues(value); break; // Is the DB2 case correct? Should it be inlined like the Postgres case? @@ -164,8 +160,8 @@ class UDTConstant> extends AbstractParam { // Postgres cannot bind a complete structured type. The type is // inlined instead: ROW(.., .., ..) case POSTGRES: { - for (Field field : record.fields()) { - context.bind(val(record.getValue(field))); + for (Field field : value.fields()) { + context.bind(val(value.getValue(field))); } break; diff --git a/jOOQ/src/main/java/org/jooq/impl/Val.java b/jOOQ/src/main/java/org/jooq/impl/Val.java index 6e90fc2a95..e19d31bb01 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Val.java +++ b/jOOQ/src/main/java/org/jooq/impl/Val.java @@ -96,7 +96,7 @@ class Val extends AbstractParam { // Casting can be enforced or prevented switch (context.castMode()) { case NEVER: - toSQL(context, getValue(), getType()); + toSQL(context, value, getType()); return; case ALWAYS: @@ -115,7 +115,7 @@ class Val extends AbstractParam { toSQLCast(context); } else { - toSQL(context, getValue(), getType()); + toSQL(context, value, getType()); } return; @@ -128,7 +128,7 @@ class Val extends AbstractParam { // Most RDBMS can infer types for bind values else { - toSQL(context, getValue(), getType()); + toSQL(context, value, getType()); } } @@ -138,7 +138,7 @@ class Val extends AbstractParam { if (!isInline(context)) { // Generated enums should not be cast... - if (!(getValue() instanceof EnumType)) { + if (!(value instanceof EnumType)) { switch (context.getDialect()) { // These dialects can hardly detect the type of a bound constant. @@ -187,11 +187,11 @@ class Val extends AbstractParam { SQLDialect dialect = context.getDialect(); // [#822] Some RDBMS need precision / scale information on BigDecimals - if (getValue() != null && getType() == BigDecimal.class && asList(CUBRID, DB2, DERBY, FIREBIRD, HSQLDB).contains(dialect)) { + if (value != null && getType() == BigDecimal.class && asList(CUBRID, DB2, DERBY, FIREBIRD, HSQLDB).contains(dialect)) { // Add precision / scale on BigDecimals - int scale = ((BigDecimal) getValue()).scale(); - int precision = scale + ((BigDecimal) getValue()).precision(); + int scale = ((BigDecimal) value).scale(); + int precision = scale + ((BigDecimal) value).precision(); // Firebird's max precision is 18 if (dialect == FIREBIRD) { @@ -205,8 +205,8 @@ class Val extends AbstractParam { else if (SQLDataType.OTHER == type) { // If the bind value is set, it can be used to derive the cast type - if (getValue() != null) { - toSQLCast(context, DefaultDataType.getDataType(dialect, getValue().getClass()), 0, 0, 0); + if (value != null) { + toSQLCast(context, DefaultDataType.getDataType(dialect, value.getClass()), 0, 0, 0); } // [#632] [#722] Current integration tests show that Ingres and @@ -227,7 +227,7 @@ class Val extends AbstractParam { // [#1125] Also with temporal data types, casting is needed some times // [#1130] TODO type can be null for ARRAY types, etc. else if (dialect == POSTGRES && (type == null || !type.isTemporal())) { - toSQL(context, getValue(), getType()); + toSQL(context, value, getType()); } // [#1727] VARCHAR types should be cast to their actual lengths in some @@ -243,7 +243,7 @@ class Val extends AbstractParam { } private int getValueLength() { - String string = (String) getValue(); + String string = (String) value; if (string == null) { return 1; } @@ -266,7 +266,7 @@ class Val extends AbstractParam { private void toSQLCast(RenderContext context, DataType type, int length, int precision, int scale) { context.keyword("cast("); - toSQL(context, getValue(), getType()); + toSQL(context, value, getType()); context.keyword(" as ") .sql(type.length(length).precision(precision, scale).getCastTypeName(context)) .sql(")"); @@ -522,7 +522,7 @@ class Val extends AbstractParam { // [#1302] Bind value only if it was not explicitly forced to be inlined if (!isInline()) { - context.bindValue(getValue(), getType()); + context.bindValue(value, getType()); } }