to store user types converting them to database types "TO" the database.
* Hence, {@link #toType()} is the user-defined type
*
+ *
+ * Note: In order to avoid unwanted side-effects, it is highly recommended (yet
+ * not required) for {@link #from(Object)} and {@link #to(Object)} to be
+ * reciprocal. The two methods are reciprocal, if for all
+ * X and Y, it can be said that
+ *
+ * - if
Y.equals(converter.from(X)), then
+ * X.equals(converter.to(Y)).
+ * -
+ *
X.equals(converter.from(converter.to(X)))
+ * X.equals(converter.to(converter.from(X)))
+ *
+ *
+ * Furthermore, it is recommended (yet not required) that
+ *
+ * converter.from(null) == null
+ * converter.to(null) == null
+ *
*
* @author Lukas Eder
* @param The database type - i.e. any type available from
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java
index 2cad4f1f4c..f0e60d87ca 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultBindContext.java
@@ -94,7 +94,7 @@ class DefaultBindContext extends AbstractBindContext {
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
protected final BindContext bindValue0(Object value, Class> type) throws SQLException {
SQLDialect dialect = configuration.getDialect();
diff --git a/jOOQ/src/main/java/org/jooq/impl/Val.java b/jOOQ/src/main/java/org/jooq/impl/Val.java
index 5ff97dd23e..f2c6976690 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Val.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Val.java
@@ -61,6 +61,7 @@ import java.util.List;
import org.jooq.ArrayRecord;
import org.jooq.Attachable;
import org.jooq.BindContext;
+import org.jooq.Converter;
import org.jooq.DataType;
import org.jooq.EnumType;
import org.jooq.MasterDataType;
@@ -254,9 +255,17 @@ class Val extends AbstractField implements Param, BindingProvider {
/**
* Inlining abstraction
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private void toSQL(RenderContext context, Object val, Class> type) {
SQLDialect dialect = context.getDialect();
+ // [#650] Check first, if we have a converter for the supplied type
+ Converter, ?> converter = DataTypes.converter(type);
+ if (converter != null) {
+ val = ((Converter) converter).to(val);
+ type = converter.fromType();
+ }
+
if (context.inline()) {
if (val == null) {
context.keyword("null");