cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [4/6] cayenne git commit: CAY-2050 Refactoring: ParameterBinding to contain ExtendedType property - switch to new api
Date Sat, 05 Mar 2016 08:21:52 GMT
CAY-2050 Refactoring: ParameterBinding to contain ExtendedType property - switch to new api


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/bfb4747d
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/bfb4747d
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/bfb4747d

Branch: refs/heads/master
Commit: bfb4747d5cd0022ea1d59ba493cde38272094c9c
Parents: 3579ecf
Author: Alexei Grigoriev <agrigoriev@objectstyle.com>
Authored: Wed Jan 27 17:16:49 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sat Mar 5 09:14:31 2016 +0100

----------------------------------------------------------------------
 .../apache/cayenne/access/jdbc/BatchAction.java | 15 ++--
 .../cayenne/access/jdbc/SQLTemplateAction.java  | 19 +---
 .../cayenne/access/jdbc/SelectAction.java       | 15 ++--
 .../access/translator/ParameterBinding.java     |  9 ++
 .../translator/ProcedureParameterBinding.java   | 66 ++++++++++++++
 .../procedure/ProcedureTranslator.java          | 21 +++--
 .../org/apache/cayenne/dba/AutoAdapter.java     | 26 ++++--
 .../java/org/apache/cayenne/dba/DbAdapter.java  | 18 +++-
 .../org/apache/cayenne/dba/JdbcAdapter.java     | 93 ++++++++++++++------
 .../org/apache/cayenne/dba/db2/DB2Adapter.java  | 15 ++--
 .../apache/cayenne/dba/derby/DerbyAdapter.java  | 13 ++-
 .../cayenne/dba/ingres/IngresAdapter.java       | 51 +++++------
 .../apache/cayenne/dba/mysql/MySQLAdapter.java  | 34 +++----
 .../dba/oracle/Oracle8LOBBatchAction.java       | 37 ++++----
 .../cayenne/dba/oracle/OracleAdapter.java       | 10 ++-
 .../cayenne/dba/postgres/PostgresAdapter.java   |  6 +-
 .../cayenne/dba/sqlite/SQLiteAdapter.java       |  5 +-
 .../cayenne/dba/sybase/SybaseAdapter.java       | 19 ++--
 .../cayenne/access/ReturnTypesMappingIT.java    |  7 +-
 19 files changed, 295 insertions(+), 184 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java b/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
index faff51c..fa0065f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/BatchAction.java
@@ -19,14 +19,6 @@
 
 package org.apache.cayenne.access.jdbc;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Collection;
-import java.util.Collections;
-
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.ResultIterator;
 import org.apache.cayenne.access.DataNode;
@@ -44,6 +36,10 @@ import org.apache.cayenne.query.BatchQuery;
 import org.apache.cayenne.query.BatchQueryRow;
 import org.apache.cayenne.query.InsertBatchQuery;
 
+import java.sql.*;
+import java.util.Collection;
+import java.util.Collections;
+
 /**
  * @since 1.2
  */
@@ -58,8 +54,7 @@ public class BatchAction extends BaseSQLAction {
 
 		for (ParameterBinding b : bindings) {
 			if (!b.isExcluded()) {
-				adapter.bindParameter(statement, b.getValue(), b.getStatementPosition(), b.getAttribute().getType(), b
-						.getAttribute().getScale());
+				adapter.bindParameter(statement, b);
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java b/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
index 97a1067..b309ba3 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
@@ -19,19 +19,6 @@
 
 package org.apache.cayenne.access.jdbc;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ResultIterator;
@@ -51,6 +38,9 @@ import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.util.Util;
 import org.apache.commons.collections.IteratorUtils;
 
+import java.sql.*;
+import java.util.*;
+
 /**
  * Implements a strategy for execution of SQLTemplates.
  * 
@@ -349,8 +339,7 @@ public class SQLTemplateAction implements SQLAction {
 		if (bindings.length > 0) {
 			int len = bindings.length;
 			for (int i = 0; i < len; i++) {
-				dataNode.getAdapter().bindParameter(preparedStatement, bindings[i].getValue(), i + 1,
-						bindings[i].getJdbcType(), bindings[i].getScale());
+				dataNode.getAdapter().bindParameter(preparedStatement, bindings[i], i + 1);
 			}
 		}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java b/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
index f5ff8d1..16a9893 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/jdbc/SelectAction.java
@@ -19,12 +19,6 @@
 
 package org.apache.cayenne.access.jdbc;
 
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.ResultIterator;
 import org.apache.cayenne.access.DataNode;
@@ -39,6 +33,12 @@ import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.QueryMetadata;
 import org.apache.cayenne.query.SelectQuery;
 
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
 /**
  * A SQLAction that handles SelectQuery execution.
  * 
@@ -62,8 +62,7 @@ public class SelectAction extends BaseSQLAction {
 			if (b.getAttribute() == null) {
 				statement.setObject(b.getStatementPosition(), b.getValue());
 			} else {
-				adapter.bindParameter(statement, b.getValue(), b.getStatementPosition(), b.getAttribute().getType(), b
-						.getAttribute().getScale());
+				adapter.bindParameter(statement, b);
 			}
 		}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ParameterBinding.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ParameterBinding.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ParameterBinding.java
index 336dd3b..fb5bbcb 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ParameterBinding.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ParameterBinding.java
@@ -34,6 +34,7 @@ public class ParameterBinding {
 	private Object value;
 	private int statementPosition;
 	private ExtendedType extendedType;
+	private Integer type;
 
 	public ParameterBinding(DbAttribute attribute, ExtendedType extendedType) {
 		this.attribute = attribute;
@@ -85,4 +86,12 @@ public class ParameterBinding {
 		this.statementPosition = statementPosition;
 		this.value = value;
 	}
+
+	public Integer getType() {
+		return type != null ? type : attribute.getType();
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ProcedureParameterBinding.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ProcedureParameterBinding.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ProcedureParameterBinding.java
new file mode 100644
index 0000000..e1a72ed
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ProcedureParameterBinding.java
@@ -0,0 +1,66 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access.translator;
+
+import org.apache.cayenne.access.types.ExtendedType;
+import org.apache.cayenne.map.ProcedureParameter;
+
+/**
+ * Describes a PreparedStatement parameter binding mapped to a CallableStatment.
+ * 
+ * @since 4.0
+ */
+public class ProcedureParameterBinding {
+	public ProcedureParameterBinding(ProcedureParameter param) {
+		this.param = param;
+	}
+
+	private final ProcedureParameter param;
+	private Object value;
+	private int statementPosition;
+	private ExtendedType extendedType;
+
+	public ProcedureParameter getParam() {
+		return param;
+	}
+
+	public Object getValue() {
+		return value;
+	}
+
+	public void setValue(Object value) {
+		this.value = value;
+	}
+
+	public int getStatementPosition() {
+		return statementPosition;
+	}
+
+	public void setStatementPosition(int statementPosition) {
+		this.statementPosition = statementPosition;
+	}
+
+	public ExtendedType getExtendedType() {
+		return extendedType;
+	}
+
+	public void setExtendedType(ExtendedType extendedType) {
+		this.extendedType = extendedType;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/access/translator/procedure/ProcedureTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/procedure/ProcedureTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/procedure/ProcedureTranslator.java
index 12d291e..f6021f2 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/procedure/ProcedureTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/procedure/ProcedureTranslator.java
@@ -19,13 +19,7 @@
 
 package org.apache.cayenne.access.translator.procedure;
 
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
+import org.apache.cayenne.access.translator.ProcedureParameterBinding;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.log.JdbcEventLogger;
 import org.apache.cayenne.log.NoopJdbcEventLogger;
@@ -34,6 +28,13 @@ import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.ProcedureParameter;
 import org.apache.cayenne.query.ProcedureQuery;
 
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 /**
  * Stored procedure query translator.
  */
@@ -230,8 +231,10 @@ public class ProcedureTranslator {
             Object val,
             int pos) throws Exception {
 
-        int type = param.getType();
-        adapter.bindParameter(stmt, val, pos, type, param.getPrecision());
+        ProcedureParameterBinding binding = new ProcedureParameterBinding(param);
+        binding.setValue(val);
+        binding.setStatementPosition(pos);
+        adapter.bindParameter(stmt, binding);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/AutoAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
index 0976763..8df16f1 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
@@ -19,12 +19,11 @@
 
 package org.apache.cayenne.dba;
 
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Collection;
-
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
+import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.ProcedureParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
@@ -41,6 +40,11 @@ import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SelectQuery;
 
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Collection;
+
 /**
  * A DbAdapter that automatically detects the kind of database it is running on
  * and instantiates an appropriate DB-specific adapter, delegating all
@@ -199,9 +203,19 @@ public class AutoAdapter implements DbAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int precision)
+	public void bindParameter(PreparedStatement statement, ParameterBinding parameterBinding)
 			throws SQLException, Exception {
-		getAdapter().bindParameter(statement, object, pos, sqlType, precision);
+		getAdapter().bindParameter(statement, parameterBinding);
+	}
+
+	@Override
+	public void bindParameter(PreparedStatement statement, SQLParameterBinding parameterBinding, int position) throws SQLException, Exception {
+		getAdapter().bindParameter(statement, parameterBinding, position);
+	}
+
+	@Override
+	public void bindParameter(CallableStatement statement, ProcedureParameterBinding binding) throws SQLException, Exception {
+		getAdapter().bindParameter(statement, binding);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/DbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/DbAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/DbAdapter.java
index b71a741..6cf4eb0 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/DbAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/DbAdapter.java
@@ -19,6 +19,9 @@
 package org.apache.cayenne.dba;
 
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
+import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.ProcedureParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
@@ -33,6 +36,7 @@ import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SelectQuery;
 
+import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.util.Collection;
@@ -167,7 +171,19 @@ public interface DbAdapter {
 	/**
 	 * Binds an object value to PreparedStatement's numbered parameter.
 	 */
-	void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale)
+	void bindParameter(PreparedStatement statement, ParameterBinding parameterBinding)
+			throws SQLException, Exception;
+
+	/**
+	 * Binds an object value to PreparedStatement's numbered parameter.
+	 */
+	void bindParameter(PreparedStatement statement, SQLParameterBinding parameterBinding, int position)
+			throws SQLException, Exception;
+
+	/**
+	 * Binds an object value to CallableStatement's numbered parameter.
+	 */
+	void bindParameter(CallableStatement statement, ProcedureParameterBinding binding)
 			throws SQLException, Exception;
 
 	/**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
index 243d3f7..773f069 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
@@ -21,6 +21,9 @@ package org.apache.cayenne.dba;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.jdbc.SQLParameterBinding;
+import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.ProcedureParameterBinding;
 import org.apache.cayenne.access.translator.batch.BatchTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory;
@@ -49,6 +52,7 @@ import org.apache.cayenne.resource.ResourceLocator;
 import org.apache.cayenne.util.Util;
 
 import java.net.URL;
+import java.sql.CallableStatement;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Types;
@@ -79,7 +83,7 @@ public class JdbcAdapter implements DbAdapter {
 	/**
 	 * @since 3.1
 	 * @deprecated since 4.0 BatchQueryBuilderfactory is attached to the
-	 *             DataNode.
+	 * DataNode.
 	 */
 	@Inject
 	protected BatchTranslatorFactory batchQueryBuilderFactory;
@@ -91,10 +95,10 @@ public class JdbcAdapter implements DbAdapter {
 	 * Creates new JdbcAdapter with a set of default parameters.
 	 */
 	public JdbcAdapter(@Inject RuntimeProperties runtimeProperties,
-			@Inject(Constants.SERVER_DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes,
-			@Inject(Constants.SERVER_USER_TYPES_LIST) List<ExtendedType> userExtendedTypes,
-			@Inject(Constants.SERVER_TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories,
-			@Inject(Constants.SERVER_RESOURCE_LOCATOR) ResourceLocator resourceLocator) {
+	                   @Inject(Constants.SERVER_DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes,
+	                   @Inject(Constants.SERVER_USER_TYPES_LIST) List<ExtendedType> userExtendedTypes,
+	                   @Inject(Constants.SERVER_TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories,
+	                   @Inject(Constants.SERVER_RESOURCE_LOCATOR) ResourceLocator resourceLocator) {
 
 		// init defaults
 		this.setSupportsBatchUpdates(false);
@@ -113,7 +117,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Returns default separator - a semicolon.
-	 * 
+	 *
 	 * @since 1.0.4
 	 */
 	@Override
@@ -137,7 +141,7 @@ public class JdbcAdapter implements DbAdapter {
 	 * well. Resource lookup is recursive, so that if DbAdapter is a subclass of
 	 * another adapter, parent adapter package is searched as a failover.
 	 * </p>
-	 * 
+	 *
 	 * @since 3.0
 	 */
 	protected URL findResource(String name) {
@@ -172,7 +176,7 @@ public class JdbcAdapter implements DbAdapter {
 	 * @since 3.1
 	 */
 	protected void initExtendedTypes(List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes,
-			List<ExtendedTypeFactory> extendedTypeFactories) {
+	                                 List<ExtendedTypeFactory> extendedTypeFactories) {
 		for (ExtendedType type : defaultExtendedTypes) {
 			extendedTypes.registerType(type);
 		}
@@ -201,7 +205,7 @@ public class JdbcAdapter implements DbAdapter {
 	 * Creates and returns an {@link EJBQLTranslatorFactory} used to generate
 	 * visitors for EJBQL to SQL translations. This method should be overriden
 	 * by subclasses that need to customize EJBQL generation.
-	 * 
+	 *
 	 * @since 3.0
 	 */
 	protected EJBQLTranslatorFactory createEJBQLTranslatorFactory() {
@@ -220,7 +224,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Sets new primary key generator.
-	 * 
+	 *
 	 * @since 1.1
 	 */
 	public void setPkGenerator(PkGenerator pkGenerator) {
@@ -229,7 +233,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Returns true.
-	 * 
+	 *
 	 * @since 1.1
 	 */
 	@Override
@@ -257,7 +261,7 @@ public class JdbcAdapter implements DbAdapter {
 	/**
 	 * Returns true if supplied type can have a length attribute as a part of
 	 * column definition
-	 * 
+	 *
 	 * @since 4.0
 	 */
 	public boolean typeSupportsLength(int type) {
@@ -267,11 +271,11 @@ public class JdbcAdapter implements DbAdapter {
 	/**
 	 * Returns true if supplied type can have a length attribute as a part of
 	 * column definition
-	 * 
+	 * <p/>
 	 * TODO: this is a static method only to support the deprecated method
 	 * {@link TypesMapping#supportsLength(int)} When the deprecated method is
 	 * removed this body should be moved in to {@link #typeSupportsLength(int)}
-	 * 
+	 *
 	 * @deprecated
 	 */
 	static boolean supportsLength(int type) {
@@ -360,7 +364,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Appends SQL for column creation to CREATE TABLE buffer.
-	 * 
+	 *
 	 * @since 1.2
 	 */
 	@Override
@@ -405,7 +409,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Returns a DDL string to create a unique constraint over a set of columns.
-	 * 
+	 *
 	 * @since 1.1
 	 */
 	@Override
@@ -525,7 +529,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Uses JdbcActionBuilder to create the right action.
-	 * 
+	 *
 	 * @since 1.2
 	 */
 	@Override
@@ -539,14 +543,47 @@ public class JdbcAdapter implements DbAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale)
+	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
 			throws SQLException, Exception {
 
-		if (object == null) {
-			statement.setNull(pos, sqlType);
+		if (binding.getValue() == null) {
+			statement.setNull(binding.getStatementPosition(), binding.getType());
 		} else {
-			ExtendedType typeProcessor = getExtendedTypes().getRegisteredType(object.getClass());
-			typeProcessor.setJdbcObject(statement, object, pos, sqlType, scale);
+			ExtendedType typeProcessor = getExtendedTypes().getRegisteredType(binding.getValue().getClass());
+			typeProcessor.setJdbcObject(statement
+					, binding.getValue()
+					, binding.getStatementPosition()
+					, binding.getType()
+					, binding.getAttribute().getScale());
+		}
+	}
+
+	@Override
+	public void bindParameter(PreparedStatement statement, SQLParameterBinding binding, int position) throws
+			SQLException, Exception {
+		if (binding.getValue() == null) {
+			statement.setNull(position, binding.getJdbcType());
+		} else {
+			ExtendedType typeProcessor = getExtendedTypes().getRegisteredType(binding.getValue().getClass());
+			typeProcessor.setJdbcObject(statement
+					, binding.getValue()
+					, position
+					, binding.getJdbcType()
+					, binding.getScale());
+		}
+	}
+
+	@Override
+	public void bindParameter(CallableStatement statement, ProcedureParameterBinding binding) throws SQLException, Exception {
+		if (binding.getValue() == null) {
+			statement.setNull(binding.getStatementPosition(), binding.getParam().getType());
+		} else {
+			ExtendedType typeProcessor = getExtendedTypes().getRegisteredType(binding.getValue().getClass());
+			typeProcessor.setJdbcObject(statement
+					, binding.getValue()
+					, binding.getStatementPosition()
+					, binding.getParam().getType()
+					, binding.getParam().getPrecision());
 		}
 	}
 
@@ -579,7 +616,7 @@ public class JdbcAdapter implements DbAdapter {
 	 * normally initialized in constructor by calling
 	 * {@link #createEJBQLTranslatorFactory()}, and can be changed later by
 	 * calling {@link #setEjbqlTranslatorFactory(EJBQLTranslatorFactory)}.
-	 * 
+	 *
 	 * @since 3.0
 	 */
 	public EJBQLTranslatorFactory getEjbqlTranslatorFactory() {
@@ -591,7 +628,7 @@ public class JdbcAdapter implements DbAdapter {
 	 * normally initialized in constructor by calling
 	 * {@link #createEJBQLTranslatorFactory()}, so users would only override it
 	 * if they need to customize EJBQL translation.
-	 * 
+	 *
 	 * @since 3.0
 	 */
 	public void setEjbqlTranslatorFactory(EJBQLTranslatorFactory ejbqlTranslatorFactory) {
@@ -606,8 +643,8 @@ public class JdbcAdapter implements DbAdapter {
 	}
 
 	/**
-	 * @since 4.0
 	 * @return
+	 * @since 4.0
 	 */
 	protected QuotingStrategy createQuotingStrategy() {
 		return new DefaultQuotingStrategy("\"", "\"");
@@ -632,7 +669,7 @@ public class JdbcAdapter implements DbAdapter {
 	/**
 	 * @since 3.1
 	 * @deprecated since 4.0 BatchQueryBuilderfactory is attached to the
-	 *             DataNode.
+	 * DataNode.
 	 */
 	@Deprecated
 	public BatchTranslatorFactory getBatchQueryBuilderFactory() {
@@ -642,7 +679,7 @@ public class JdbcAdapter implements DbAdapter {
 	/**
 	 * @since 3.1
 	 * @deprecated since 4.0 BatchQueryBuilderfactory is attached to the
-	 *             DataNode.
+	 * DataNode.
 	 */
 	@Deprecated
 	public void setBatchQueryBuilderFactory(BatchTranslatorFactory batchQueryBuilderFactory) {
@@ -651,7 +688,7 @@ public class JdbcAdapter implements DbAdapter {
 
 	/**
 	 * Simply returns this, as JdbcAdapter is not a wrapper.
-	 * 
+	 *
 	 * @since 4.0
 	 */
 	@Override

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
index 5064fd1..35efb99 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.dba.db2;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
 import org.apache.cayenne.access.types.BooleanType;
@@ -233,17 +234,13 @@ public class DB2Adapter extends JdbcAdapter {
 
     @Override
     public void bindParameter(
-            PreparedStatement statement,
-            Object object,
-            int pos,
-            int sqlType,
-            int precision) throws SQLException, Exception {
-
-        if (object == null && (sqlType == 0 || sqlType == Types.BOOLEAN)) {
-            statement.setNull(pos, Types.VARCHAR);
+            PreparedStatement statement, ParameterBinding binding) throws SQLException, Exception {
+
+        if (binding.getValue() == null && (binding.getAttribute().getType() == 0 || binding.getAttribute().getType() == Types.BOOLEAN)) {
+            statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
         }
         else {
-            super.bindParameter(statement, object, pos, sqlType, precision);
+            super.bindParameter(statement, binding);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
index dca2dc6..c9c5a0d 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
@@ -20,6 +20,7 @@
 package org.apache.cayenne.dba.derby;
 
 import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
@@ -191,15 +192,13 @@ public class DerbyAdapter extends JdbcAdapter {
     @Override
     public void bindParameter(
             PreparedStatement statement,
-            Object object,
-            int pos,
-            int sqlType,
-            int precision) throws SQLException, Exception {
+            ParameterBinding binding) throws SQLException, Exception {
 
-        if (object == null && sqlType == 0) {
-            statement.setNull(pos, Types.VARCHAR);
+        if (binding.getValue() == null && binding.getAttribute().getType() == 0) {
+            statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
         } else {
-            super.bindParameter(statement, object, pos, convertNTypes(sqlType), precision);
+            binding.setType(convertNTypes(binding.getType()));
+            super.bindParameter(statement, binding);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
index 886cf20..5da2682 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
@@ -1,26 +1,27 @@
 /*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  ****************************************************************/
 
 package org.apache.cayenne.dba.ingres;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
@@ -51,7 +52,7 @@ import java.util.List;
  * DbAdapter implementation for <a
  * href="http://opensource.ca.com/projects/ingres/">Ingres</a>. Sample
  * connection settings to use with Ingres are shown below:
- * 
+ *
  * <pre>
  *  ingres.jdbc.username = test
  *  ingres.jdbc.password = secret
@@ -64,10 +65,10 @@ public class IngresAdapter extends JdbcAdapter {
 	public static final String TRIM_FUNCTION = "TRIM";
 
 	public IngresAdapter(@Inject RuntimeProperties runtimeProperties,
-			@Inject(Constants.SERVER_DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes,
-			@Inject(Constants.SERVER_USER_TYPES_LIST) List<ExtendedType> userExtendedTypes,
-			@Inject(Constants.SERVER_TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories,
-			@Inject(Constants.SERVER_RESOURCE_LOCATOR) ResourceLocator resourceLocator) {
+	                     @Inject(Constants.SERVER_DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes,
+	                     @Inject(Constants.SERVER_USER_TYPES_LIST) List<ExtendedType> userExtendedTypes,
+	                     @Inject(Constants.SERVER_TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories,
+	                     @Inject(Constants.SERVER_RESOURCE_LOCATOR) ResourceLocator resourceLocator) {
 		super(runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories, resourceLocator);
 		setSupportsUniqueConstraints(true);
 		setSupportsGeneratedKeys(true);
@@ -109,13 +110,13 @@ public class IngresAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale)
+	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
 			throws SQLException, Exception {
 
-		if (object == null && (sqlType == Types.BOOLEAN || sqlType == Types.BIT)) {
-			statement.setNull(pos, Types.VARCHAR);
+		if (binding.getValue() == null && (binding.getAttribute().getType() == Types.BOOLEAN || binding.getAttribute().getType() == Types.BIT)) {
+			statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
 		} else {
-			super.bindParameter(statement, object, pos, sqlType, scale);
+			super.bindParameter(statement, binding);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
index 188f859..961f653 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
@@ -19,36 +19,18 @@
 
 package org.apache.cayenne.dba.mysql;
 
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
-import org.apache.cayenne.access.types.ByteArrayType;
-import org.apache.cayenne.access.types.CharType;
-import org.apache.cayenne.access.types.ExtendedType;
-import org.apache.cayenne.access.types.ExtendedTypeFactory;
-import org.apache.cayenne.access.types.ExtendedTypeMap;
+import org.apache.cayenne.access.types.*;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
-import org.apache.cayenne.dba.DefaultQuotingStrategy;
-import org.apache.cayenne.dba.JdbcAdapter;
-import org.apache.cayenne.dba.PkGenerator;
-import org.apache.cayenne.dba.QuotingStrategy;
-import org.apache.cayenne.dba.TypesMapping;
+import org.apache.cayenne.dba.*;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -60,6 +42,11 @@ import org.apache.cayenne.query.SQLAction;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.resource.ResourceLocator;
 
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.*;
+
 /**
  * DbAdapter implementation for <a href="http://www.mysql.com">MySQL RDBMS</a>.
  * <h3>
@@ -215,9 +202,10 @@ public class MySQLAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale)
+	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
 			throws SQLException, Exception {
-		super.bindParameter(statement, object, pos, mapNTypes(sqlType), scale);
+		binding.setType(mapNTypes(binding.getType()));
+		super.bindParameter(statement, binding);
 	}
 
 	private int mapNTypes(int sqlType) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java
index 8c6a7fb..3b0c829 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java
@@ -19,19 +19,6 @@
 
 package org.apache.cayenne.dba.oracle;
 
-import java.io.OutputStream;
-import java.io.Writer;
-import java.lang.reflect.Method;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Collections;
-import java.util.List;
-
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.OperationObserver;
@@ -39,13 +26,16 @@ import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.log.JdbcEventLogger;
 import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.query.BatchQuery;
-import org.apache.cayenne.query.BatchQueryRow;
-import org.apache.cayenne.query.InsertBatchQuery;
-import org.apache.cayenne.query.SQLAction;
-import org.apache.cayenne.query.UpdateBatchQuery;
+import org.apache.cayenne.query.*;
 import org.apache.cayenne.util.Util;
 
+import java.io.OutputStream;
+import java.io.Writer;
+import java.lang.reflect.Method;
+import java.sql.*;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * @since 3.0
  */
@@ -59,8 +49,9 @@ class Oracle8LOBBatchAction implements SQLAction {
 			throws SQLException, Exception {
 
 		for (ParameterBinding b : bindings) {
-			adapter.bindParameter(statement, b.getValue(), b.getStatementPosition(), b.getAttribute().getType(), b
-					.getAttribute().getScale());
+			ParameterBinding binding = new ParameterBinding(b.getAttribute(), adapter.getExtendedTypes()
+					.getRegisteredType(b.getValue().getClass()));
+			adapter.bindParameter(statement, binding);
 		}
 	}
 
@@ -150,7 +141,11 @@ class Oracle8LOBBatchAction implements SQLAction {
 				Object value = qualifierValues.get(i);
 				DbAttribute attribute = qualifierAttributes.get(i);
 
-				adapter.bindParameter(selectStatement, value, i + 1, attribute.getType(), attribute.getScale());
+				ParameterBinding binding = new ParameterBinding(attribute, adapter.getExtendedTypes()
+						.getRegisteredType(value.getClass()));
+				binding.setStatementPosition(i + 1);
+				binding.setValue(value);
+				adapter.bindParameter(selectStatement,binding);
 			}
 
 			try (ResultSet result = selectStatement.executeQuery();) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
index b0c6afa..24f06b8 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.dba.oracle;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
@@ -230,17 +231,18 @@ public class OracleAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale)
+	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
 			throws SQLException, Exception {
 
 		// Oracle doesn't support BOOLEAN even when binding NULL, so have to
 		// intercept
 		// NULL Boolean here, as super doesn't pass it through ExtendedType...
-		if (object == null && sqlType == Types.BOOLEAN) {
+		if (binding.getValue() == null && binding.getAttribute().getType() == Types.BOOLEAN) {
 			ExtendedType typeProcessor = getExtendedTypes().getRegisteredType(Boolean.class);
-			typeProcessor.setJdbcObject(statement, object, pos, sqlType, scale);
+			typeProcessor.setJdbcObject(statement, binding.getValue(), binding.getStatementPosition(), binding
+							.getAttribute().getType(),binding.getAttribute().getScale());
 		} else {
-			super.bindParameter(statement, object, pos, sqlType, scale);
+			super.bindParameter(statement, binding);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
index ee45df1..e4c7eff 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
@@ -21,6 +21,7 @@ package org.apache.cayenne.dba.postgres;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
@@ -130,9 +131,10 @@ public class PostgresAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale)
+	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
 			throws SQLException, Exception {
-		super.bindParameter(statement, object, pos, mapNTypes(sqlType), scale);
+		binding.setType(mapNTypes(binding.getType()));
+		super.bindParameter(statement, binding);
 	}
 
 	private int mapNTypes(int sqlType) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
index f82fc3f..29afb68 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
@@ -19,6 +19,7 @@
 package org.apache.cayenne.dba.sqlite;
 
 import org.apache.cayenne.access.DataNode;
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.access.types.ExtendedTypeFactory;
 import org.apache.cayenne.access.types.ExtendedTypeMap;
@@ -102,8 +103,8 @@ public class SQLiteAdapter extends JdbcAdapter {
     }
 
     @Override
-    public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int scale) throws SQLException, Exception {
-        super.bindParameter(statement, object, pos, mapNTypes(sqlType), scale);
+    public void bindParameter(PreparedStatement statement, ParameterBinding binding) throws SQLException, Exception {
+        super.bindParameter(statement, binding);
     }
 
     private int mapNTypes(int sqlType) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
index 45a6f65..b7592d4 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sybase/SybaseAdapter.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.dba.sybase;
 
+import org.apache.cayenne.access.translator.ParameterBinding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.types.ByteArrayType;
 import org.apache.cayenne.access.types.ByteType;
@@ -109,22 +110,22 @@ public class SybaseAdapter extends JdbcAdapter {
     }
 
     @Override
-    public void bindParameter(PreparedStatement statement, Object object, int pos, int sqlType, int precision)
+    public void bindParameter(PreparedStatement statement, ParameterBinding binding)
             throws SQLException, Exception {
 
         // Sybase driver doesn't like CLOBs and BLOBs as parameters
-        if (object == null) {
-            if (sqlType == Types.CLOB) {
-                sqlType = Types.VARCHAR;
-            } else if (sqlType == Types.BLOB) {
-                sqlType = Types.VARBINARY;
+        if (binding.getValue() == null) {
+            if (binding.getAttribute().getType() == Types.CLOB) {
+                binding.getAttribute().setType(Types.VARCHAR);
+            } else if (binding.getAttribute().getType() == Types.BLOB) {
+                binding.getAttribute().setType(Types.VARBINARY);
             }
         }
 
-        if (object == null && sqlType == 0) {
-            statement.setNull(pos, Types.VARCHAR);
+        if (binding.getValue() == null && binding.getAttribute().getType() == 0) {
+            statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
         } else {
-            super.bindParameter(statement, object, pos, sqlType, precision);
+            super.bindParameter(statement, binding);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bfb4747d/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
index 4426e78..6fe3937 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
@@ -38,17 +38,14 @@ import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeThat;
+import static org.junit.Assert.*;
 import static org.junit.Assume.assumeTrue;
 
 /**
  * Test Types mapping for selected columns
  */
 @UseServerRuntime(CayenneProjects.RETURN_TYPES_PROJECT)
-public class ReturnTypesMappingIT extends ServerCase {
+public class    ReturnTypesMappingIT extends ServerCase {
 
     @Inject
     private DataContext context;


Mime
View raw message