cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [3/6] cayenne git commit: CAY-2050 parameter binding with better encapsulation
Date Sat, 05 Mar 2016 08:21:51 GMT
CAY-2050 parameter binding with better encapsulation


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

Branch: refs/heads/master
Commit: 2d3f999b0360936d25a9f08d7eea7e2dd07dbe04
Parents: 360d642
Author: Alexei Grigoriev <agrigoriev@objectstyle.com>
Authored: Tue Feb 16 14:15:23 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sat Mar 5 09:14:31 2016 +0100

----------------------------------------------------------------------
 .../CryptoBatchTranslatorFactoryDecorator.java  |   8 +-
 .../crypto/transformer/BindingsTransformer.java |   4 +-
 .../transformer/DefaultBindingsTransformer.java |   6 +-
 .../transformer/DefaultTransformerFactory.java  |  14 +-
 .../crypto/transformer/TransformerFactory.java  |   4 +-
 .../apache/cayenne/access/jdbc/BatchAction.java |  10 +-
 .../cayenne/access/jdbc/SQLTemplateAction.java  |  11 +-
 .../cayenne/access/jdbc/SelectAction.java       |   8 +-
 .../cayenne/access/translator/Binding.java      |  99 ++++
 .../access/translator/DbAttributeBinding.java   |  51 +++
 .../access/translator/ParameterBinding.java     |  97 ----
 .../translator/ProcedureParameterBinding.java   |  77 ++--
 .../translator/batch/BatchTranslator.java       |   6 +-
 .../batch/DefaultBatchTranslator.java           |  12 +-
 .../translator/batch/DeleteBatchTranslator.java |  12 +-
 .../translator/batch/InsertBatchTranslator.java |  12 +-
 .../batch/SoftDeleteBatchTranslator.java        |  14 +-
 .../translator/batch/UpdateBatchTranslator.java |  12 +-
 .../procedure/ProcedureTranslator.java          | 453 +++++++++----------
 .../translator/select/QueryAssembler.java       |  12 +-
 .../translator/select/SelectTranslator.java     |   4 +-
 .../org/apache/cayenne/dba/AutoAdapter.java     |  17 +-
 .../java/org/apache/cayenne/dba/DbAdapter.java  |  76 ++--
 .../org/apache/cayenne/dba/JdbcAdapter.java     |  42 +-
 .../org/apache/cayenne/dba/db2/DB2Adapter.java  |  13 +-
 .../apache/cayenne/dba/derby/DerbyAdapter.java  |  13 +-
 .../cayenne/dba/ingres/IngresAdapter.java       |   6 +-
 .../apache/cayenne/dba/mysql/MySQLAdapter.java  |   4 +-
 .../dba/oracle/Oracle8LOBBatchAction.java       |  12 +-
 .../dba/oracle/Oracle8LOBBatchTranslator.java   |  12 +-
 .../cayenne/dba/oracle/OracleAdapter.java       |  27 +-
 .../cayenne/dba/postgres/PostgresAdapter.java   |   4 +-
 .../cayenne/dba/sqlite/SQLiteAdapter.java       |   8 -
 .../cayenne/dba/sybase/SybaseAdapter.java       |  22 +-
 .../cayenne/log/CommonsJdbcEventLogger.java     |  12 +-
 .../org/apache/cayenne/log/JdbcEventLogger.java |  12 +-
 .../apache/cayenne/log/NoopJdbcEventLogger.java |   6 +-
 .../batch/DefaultBatchTranslatorIT.java         |  26 +-
 38 files changed, 591 insertions(+), 647 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/batch/CryptoBatchTranslatorFactoryDecorator.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/batch/CryptoBatchTranslatorFactoryDecorator.java b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/batch/CryptoBatchTranslatorFactoryDecorator.java
index e86e564..4b8a471 100644
--- a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/batch/CryptoBatchTranslatorFactoryDecorator.java
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/batch/CryptoBatchTranslatorFactoryDecorator.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.crypto.batch;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.translator.batch.BatchTranslator;
 import org.apache.cayenne.access.translator.batch.BatchTranslatorFactory;
 import org.apache.cayenne.crypto.transformer.BindingsTransformer;
@@ -65,16 +65,16 @@ public class CryptoBatchTranslatorFactoryDecorator implements BatchTranslatorFac
             }
 
             @Override
-            public ParameterBinding[] getBindings() {
+            public DbAttributeBinding[] getBindings() {
                 return delegateTranslator.getBindings();
             }
 
             @Override
-            public ParameterBinding[] updateBindings(BatchQueryRow row) {
+            public DbAttributeBinding[] updateBindings(BatchQueryRow row) {
 
                 ensureEncryptorCompiled();
 
-                ParameterBinding[] bindings = delegateTranslator.updateBindings(row);
+                DbAttributeBinding[] bindings = delegateTranslator.updateBindings(row);
 
                 if (encryptor != null) {
                     encryptor.transform(bindings);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/BindingsTransformer.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/BindingsTransformer.java b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/BindingsTransformer.java
index c6f9577..1ffded8 100644
--- a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/BindingsTransformer.java
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/BindingsTransformer.java
@@ -18,12 +18,12 @@
  ****************************************************************/
 package org.apache.cayenne.crypto.transformer;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 
 /**
  * @since 4.0
  */
 public interface BindingsTransformer {
 
-    void transform(ParameterBinding[] bindings);
+    void transform(DbAttributeBinding[] bindings);
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultBindingsTransformer.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultBindingsTransformer.java b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultBindingsTransformer.java
index db31eea..e8aeb4b 100644
--- a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultBindingsTransformer.java
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultBindingsTransformer.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.crypto.transformer;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.crypto.transformer.bytes.BytesEncryptor;
 import org.apache.cayenne.crypto.transformer.value.ValueEncryptor;
 
@@ -38,12 +38,12 @@ public class DefaultBindingsTransformer implements BindingsTransformer {
     }
 
     @Override
-    public void transform(ParameterBinding[] bindings) {
+    public void transform(DbAttributeBinding[] bindings) {
 
         int len = positions.length;
 
         for (int i = 0; i < len; i++) {
-            ParameterBinding b = bindings[positions[i]];
+            DbAttributeBinding b = bindings[positions[i]];
             Object transformed = transformers[i].encrypt(encryptor, b.getValue());
             b.setValue(transformed);
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultTransformerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultTransformerFactory.java b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultTransformerFactory.java
index 178a2f8..09a56ef 100644
--- a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultTransformerFactory.java
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/DefaultTransformerFactory.java
@@ -18,12 +18,8 @@
  ****************************************************************/
 package org.apache.cayenne.crypto.transformer;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.crypto.map.ColumnMapper;
 import org.apache.cayenne.crypto.transformer.bytes.BytesTransformerFactory;
 import org.apache.cayenne.crypto.transformer.value.ValueDecryptor;
@@ -32,6 +28,10 @@ import org.apache.cayenne.crypto.transformer.value.ValueTransformerFactory;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @since 4.0
  */
@@ -90,7 +90,7 @@ public class DefaultTransformerFactory implements TransformerFactory {
     }
 
     @Override
-    public BindingsTransformer encryptor(ParameterBinding[] bindings) {
+    public BindingsTransformer encryptor(DbAttributeBinding[] bindings) {
         int len = bindings.length;
         List<Integer> cryptoColumns = null;
 
@@ -115,7 +115,7 @@ public class DefaultTransformerFactory implements TransformerFactory {
 
             for (int i = 0; i < dlen; i++) {
                 int pos = cryptoColumns.get(i);
-                ParameterBinding b = bindings[pos];
+                DbAttributeBinding b = bindings[pos];
                 positions[i] = pos;
                 transformers[i] = transformerFactory.encryptor(b.getAttribute());
             }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/TransformerFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/TransformerFactory.java b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/TransformerFactory.java
index 9bc28a8..a8893d1 100644
--- a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/TransformerFactory.java
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/transformer/TransformerFactory.java
@@ -19,7 +19,7 @@
 package org.apache.cayenne.crypto.transformer;
 
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 
 /**
  * A factory that creates encryption transformers used for processing batch
@@ -29,7 +29,7 @@ import org.apache.cayenne.access.translator.ParameterBinding;
  */
 public interface TransformerFactory {
 
-    BindingsTransformer encryptor(ParameterBinding[] bindings);
+    BindingsTransformer encryptor(DbAttributeBinding[] bindings);
 
     MapTransformer decryptor(ColumnDescriptor[] columns, Object sampleRow);
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 fa0065f..7746823 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
@@ -25,7 +25,7 @@ import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.OptimisticLockException;
 import org.apache.cayenne.access.jdbc.reader.RowReader;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.translator.batch.BatchTranslator;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.TypesMapping;
@@ -49,10 +49,10 @@ public class BatchAction extends BaseSQLAction {
 	protected BatchQuery query;
 	protected RowDescriptor keyRowDescriptor;
 
-	private static void bind(DbAdapter adapter, PreparedStatement statement, ParameterBinding[] bindings)
+	private static void bind(DbAdapter adapter, PreparedStatement statement, DbAttributeBinding[] bindings)
 			throws SQLException, Exception {
 
-		for (ParameterBinding b : bindings) {
+		for (DbAttributeBinding b : bindings) {
 			if (!b.isExcluded()) {
 				adapter.bindParameter(statement, b);
 			}
@@ -109,7 +109,7 @@ public class BatchAction extends BaseSQLAction {
 		try (PreparedStatement statement = con.prepareStatement(sql);) {
 			for (BatchQueryRow row : query.getRows()) {
 
-				ParameterBinding[] bindings = translator.updateBindings(row);
+				DbAttributeBinding[] bindings = translator.updateBindings(row);
 				logger.logQueryParameters("batch bind", bindings);
 				bind(adapter, statement, bindings);
 
@@ -161,7 +161,7 @@ public class BatchAction extends BaseSQLAction {
 				Statement.RETURN_GENERATED_KEYS) : connection.prepareStatement(queryStr);) {
 			for (BatchQueryRow row : query.getRows()) {
 
-				ParameterBinding[] bindings = translator.updateBindings(row);
+				DbAttributeBinding[] bindings = translator.updateBindings(row);
 				logger.logQueryParameters("bind", bindings);
 
 				bind(adapter, statement, bindings);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 b309ba3..0f9ac47 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
@@ -25,6 +25,8 @@ import org.apache.cayenne.ResultIterator;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.jdbc.reader.RowReader;
+import org.apache.cayenne.access.translator.Binding;
+import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.access.types.ExtendedTypeMap;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.TypesMapping;
@@ -339,7 +341,14 @@ 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], i + 1);
+				ExtendedType extendedType = getAdapter().getExtendedTypes().getDefaultType();
+				if (bindings[i].getValue() != null) getAdapter().getExtendedTypes().getRegisteredType(bindings[i]
+						.getValue().getClass());
+				Binding binding = new Binding(extendedType);
+				binding.setType(bindings[i].getJdbcType());
+				binding.setStatementPosition(i+1);
+				binding.setValue(bindings[i].getValue());
+				dataNode.getAdapter().bindParameter(preparedStatement, binding);
 			}
 		}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 16a9893..fc84de6 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
@@ -24,7 +24,7 @@ import org.apache.cayenne.ResultIterator;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.jdbc.reader.RowReader;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.log.JdbcEventLogger;
@@ -46,10 +46,10 @@ import java.util.List;
  */
 public class SelectAction extends BaseSQLAction {
 
-	private static void bind(DbAdapter adapter, PreparedStatement statement, ParameterBinding[] bindings)
+	private static void bind(DbAdapter adapter, PreparedStatement statement, DbAttributeBinding[] bindings)
 			throws SQLException, Exception {
 
-		for (ParameterBinding b : bindings) {
+		for (DbAttributeBinding b : bindings) {
 
 			if (b.isExcluded()) {
 				continue;
@@ -90,7 +90,7 @@ public class SelectAction extends BaseSQLAction {
 		SelectTranslator translator = dataNode.selectTranslator(query);
 		final String sql = translator.getSql();
 
-		ParameterBinding[] bindings = translator.getBindings();
+		DbAttributeBinding[] bindings = translator.getBindings();
 		PreparedStatement statement = connection.prepareStatement(sql);
 		bind(dataNode.getAdapter(), statement, bindings);
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/Binding.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/Binding.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/Binding.java
new file mode 100644
index 0000000..369f5cc
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/Binding.java
@@ -0,0 +1,99 @@
+/*****************************************************************
+ *   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;
+
+/**
+ * Describes a PreparedStatement parameter generic binding.
+ * 
+ * @since 4.0
+ */
+public class Binding {
+
+	static final int EXCLUDED_POSITION = -1;
+
+	private Object value;
+	private int statementPosition;
+	private ExtendedType extendedType;
+	private Integer type;
+	private int scale;
+
+	public Binding(ExtendedType extendedType) {
+		this.statementPosition = EXCLUDED_POSITION;
+		this.extendedType = extendedType;
+	}
+
+	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 boolean isExcluded() {
+		return statementPosition == EXCLUDED_POSITION;
+	}
+
+	public ExtendedType getExtendedType() {
+		return extendedType;
+	}
+
+	/**
+	 * Marks the binding object as excluded for the current iteration.
+	 */
+	public void exclude() {
+		this.statementPosition = EXCLUDED_POSITION;
+		this.value = null;
+	}
+
+	/**
+	 * Sets the value of the binding and initializes statement position var,
+	 * thus "including" this binding in the current iteration.
+	 */
+	public void include(int statementPosition, Object value) {
+		this.statementPosition = statementPosition;
+		this.value = value;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public int getScale() {
+		return scale;
+	}
+
+	public void setScale(int scale) {
+		this.scale = scale;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/DbAttributeBinding.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/DbAttributeBinding.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/DbAttributeBinding.java
new file mode 100644
index 0000000..05c40ab
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/DbAttributeBinding.java
@@ -0,0 +1,51 @@
+/*****************************************************************
+ *   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.DbAttribute;
+
+/**
+ * Describes a PreparedStatement parameter binding mapped to a DbAttribute.
+ * 
+ * @since 4.0
+ */
+public class DbAttributeBinding extends Binding{
+
+	private final DbAttribute attribute;
+
+	public DbAttributeBinding(DbAttribute attribute, ExtendedType extendedType) {
+		super(extendedType);
+		this.attribute = attribute;
+	}
+
+	public DbAttribute getAttribute() {
+		return attribute;
+	}
+
+	@Override
+	public Integer getType() {
+		return super.getType() != null ? super.getType() : attribute.getType();
+	}
+
+	@Override
+ 	public int getScale() {
+		return getAttribute().getScale();
+	}
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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
deleted file mode 100644
index fb5bbcb..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/ParameterBinding.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************
- *   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.DbAttribute;
-
-/**
- * Describes a PreparedStatement parameter binding mapped to a DbAttribute.
- * 
- * @since 4.0
- */
-public class ParameterBinding {
-
-	static final int EXCLUDED_POSITION = -1;
-
-	private DbAttribute attribute;
-	private Object value;
-	private int statementPosition;
-	private ExtendedType extendedType;
-	private Integer type;
-
-	public ParameterBinding(DbAttribute attribute, ExtendedType extendedType) {
-		this.attribute = attribute;
-		this.statementPosition = EXCLUDED_POSITION;
-		this.extendedType = extendedType;
-	}
-
-	public DbAttribute getAttribute() {
-		return attribute;
-	}
-
-	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 boolean isExcluded() {
-		return statementPosition == EXCLUDED_POSITION;
-	}
-
-	public ExtendedType getExtendedType() {
-		return extendedType;
-	}
-
-	/**
-	 * Marks the binding object as excluded for the current iteration.
-	 */
-	public void exclude() {
-		this.statementPosition = EXCLUDED_POSITION;
-		this.value = null;
-	}
-
-	/**
-	 * Sets the value of the binding and initializes statement position var,
-	 * thus "including" this binding in the current iteration.
-	 */
-	public void include(int statementPosition, Object value) {
-		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/2d3f999b/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
index e1a72ed..1294b86 100644
--- 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
@@ -1,20 +1,20 @@
 /*****************************************************************
- *   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.access.translator;
 
@@ -22,45 +22,30 @@ import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.map.ProcedureParameter;
 
 /**
- * Describes a PreparedStatement parameter binding mapped to a CallableStatment.
- * 
+ * Describes a PreparedStatement parameter binding mapped to a DbAttribute.
+ *
  * @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 class ProcedureParameterBinding extends Binding {
 
-	public ProcedureParameter getParam() {
-		return param;
-	}
-
-	public Object getValue() {
-		return value;
-	}
-
-	public void setValue(Object value) {
-		this.value = value;
-	}
+	private final ProcedureParameter parameter;
 
-	public int getStatementPosition() {
-		return statementPosition;
+	public ProcedureParameterBinding(ProcedureParameter procedureParameter, ExtendedType extendedType) {
+		super(extendedType);
+		this.parameter = procedureParameter;
 	}
 
-	public void setStatementPosition(int statementPosition) {
-		this.statementPosition = statementPosition;
+	public ProcedureParameter getParameter() {
+		return parameter;
 	}
 
-	public ExtendedType getExtendedType() {
-		return extendedType;
+	@Override
+	public Integer getType() {
+		return parameter.getType();
 	}
 
-	public void setExtendedType(ExtendedType extendedType) {
-		this.extendedType = extendedType;
+	@Override
+	public int getScale() {
+		return parameter.getPrecision();
 	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/BatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/BatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/BatchTranslator.java
index 04a4902..66fe58c 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/BatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/BatchTranslator.java
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.access.translator.batch;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.query.BatchQueryRow;
 
 /**
@@ -37,7 +37,7 @@ public interface BatchTranslator {
     /**
      * Returns the widest possible array of bindings for this query.
      */
-    ParameterBinding[] getBindings();
+    DbAttributeBinding[] getBindings();
 
     /**
      * Updates internal bindings to be used with a given row, returning updated
@@ -47,5 +47,5 @@ public interface BatchTranslator {
      * parameter). Usually the returned array is actually the same object reused
      * for every iteration, only with changed object state.
      */
-    ParameterBinding[] updateBindings(BatchQueryRow row);
+    DbAttributeBinding[] updateBindings(BatchQueryRow row);
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslator.java
index 732ec64..70c2a27 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DefaultBatchTranslator.java
@@ -20,7 +20,7 @@ package org.apache.cayenne.access.translator.batch;
 
 import java.sql.Types;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
@@ -40,7 +40,7 @@ public abstract class DefaultBatchTranslator implements BatchTranslator {
 
     protected boolean translated;
     protected String sql;
-    protected ParameterBinding[] bindings;
+    protected DbAttributeBinding[] bindings;
 
     public DefaultBatchTranslator(BatchQuery query, DbAdapter adapter, String trimFunction) {
         this.query = query;
@@ -67,22 +67,22 @@ public abstract class DefaultBatchTranslator implements BatchTranslator {
     }
 
     @Override
-    public ParameterBinding[] getBindings() {
+    public DbAttributeBinding[] getBindings() {
         ensureTranslated();
         return bindings;
     }
     
     @Override
-    public ParameterBinding[] updateBindings(BatchQueryRow row) {
+    public DbAttributeBinding[] updateBindings(BatchQueryRow row) {
         ensureTranslated();
         return doUpdateBindings(row);
     }
 
     protected abstract String createSql();
 
-    protected abstract ParameterBinding[] createBindings();
+    protected abstract DbAttributeBinding[] createBindings();
     
-    protected abstract ParameterBinding[] doUpdateBindings(BatchQueryRow row);
+    protected abstract DbAttributeBinding[] doUpdateBindings(BatchQueryRow row);
 
     /**
      * Appends the name of the column to the query buffer. Subclasses use this

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DeleteBatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DeleteBatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DeleteBatchTranslator.java
index 4f63e5f..9660b3f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DeleteBatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/DeleteBatchTranslator.java
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.access.translator.batch;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.QuotingStrategy;
@@ -74,26 +74,26 @@ public class DeleteBatchTranslator extends DefaultBatchTranslator {
     }
 
     @Override
-    protected ParameterBinding[] createBindings() {
+    protected DbAttributeBinding[] createBindings() {
         DeleteBatchQuery deleteBatch = (DeleteBatchQuery) query;
         List<DbAttribute> attributes = deleteBatch.getDbAttributes();
         int len = attributes.size();
 
-        ParameterBinding[] bindings = new ParameterBinding[len];
+        DbAttributeBinding[] bindings = new DbAttributeBinding[len];
 
         for (int i = 0; i < len; i++) {
             DbAttribute a = attributes.get(i);
 
             String typeName = TypesMapping.getJavaBySqlType(a.getType());
             ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
-            bindings[i] = new ParameterBinding(a, extendedType);
+            bindings[i] = new DbAttributeBinding(a, extendedType);
         }
 
         return bindings;
     }
 
     @Override
-    protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+    protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
 
         int len = bindings.length;
 
@@ -101,7 +101,7 @@ public class DeleteBatchTranslator extends DefaultBatchTranslator {
 
         for (int i = 0, j = 1; i < len; i++) {
 
-            ParameterBinding b = bindings[i];
+            DbAttributeBinding b = bindings[i];
 
             // skip null attributes... they are translated as "IS NULL"
             if (deleteBatch.isNull(b.getAttribute())) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslator.java
index 920b29f..cf52929 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/InsertBatchTranslator.java
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.access.translator.batch;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.QuotingStrategy;
@@ -84,18 +84,18 @@ public class InsertBatchTranslator extends DefaultBatchTranslator {
     }
 
     @Override
-    protected ParameterBinding[] createBindings() {
+    protected DbAttributeBinding[] createBindings() {
         List<DbAttribute> attributes = query.getDbAttributes();
         int len = attributes.size();
 
-        ParameterBinding[] bindings = new ParameterBinding[len];
+        DbAttributeBinding[] bindings = new DbAttributeBinding[len];
 
         for (int i = 0; i < len; i++) {
             DbAttribute a = attributes.get(i);
 
             String typeName = TypesMapping.getJavaBySqlType(a.getType());
             ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
-            bindings[i] = new ParameterBinding(a, extendedType);
+            bindings[i] = new DbAttributeBinding(a, extendedType);
 
             // include/exclude state depends on DbAttribute only and can be
             // precompiled here
@@ -112,12 +112,12 @@ public class InsertBatchTranslator extends DefaultBatchTranslator {
     }
 
     @Override
-    protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+    protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
         int len = bindings.length;
 
         for (int i = 0, j = 1; i < len; i++) {
 
-            ParameterBinding b = bindings[i];
+            DbAttributeBinding b = bindings[i];
 
             // exclusions are permanent
             if (!b.isExcluded()) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/SoftDeleteBatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/SoftDeleteBatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/SoftDeleteBatchTranslator.java
index 2a3b2f3..514ca26 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/SoftDeleteBatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/SoftDeleteBatchTranslator.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.access.translator.batch;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.QuotingStrategy;
@@ -56,19 +56,19 @@ public class SoftDeleteBatchTranslator extends DeleteBatchTranslator {
     }
 
     @Override
-    protected ParameterBinding[] createBindings() {
+    protected DbAttributeBinding[] createBindings() {
 
-        ParameterBinding[] superBindings = super.createBindings();
+        DbAttributeBinding[] superBindings = super.createBindings();
 
         int slen = superBindings.length;
 
-        ParameterBinding[] bindings = new ParameterBinding[slen + 1];
+        DbAttributeBinding[] bindings = new DbAttributeBinding[slen + 1];
 
         DbAttribute deleteAttribute = query.getDbEntity().getAttribute(deletedFieldName);
         String typeName = TypesMapping.getJavaBySqlType(deleteAttribute.getType());
         ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
 
-        bindings[0] = new ParameterBinding(deleteAttribute, extendedType);
+        bindings[0] = new DbAttributeBinding(deleteAttribute, extendedType);
         bindings[0].include(1, true);
         
         System.arraycopy(superBindings, 0, bindings, 1, slen);
@@ -77,7 +77,7 @@ public class SoftDeleteBatchTranslator extends DeleteBatchTranslator {
     }
 
     @Override
-    protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+    protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
         int len = bindings.length;
 
         DeleteBatchQuery deleteBatch = (DeleteBatchQuery) query;
@@ -85,7 +85,7 @@ public class SoftDeleteBatchTranslator extends DeleteBatchTranslator {
         // skip position 0... Otherwise follow super algorithm
         for (int i = 1, j = 2; i < len; i++) {
 
-            ParameterBinding b = bindings[i];
+            DbAttributeBinding b = bindings[i];
 
             // skip null attributes... they are translated as "IS NULL"
             if (deleteBatch.isNull(b.getAttribute())) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslator.java
index 0ad6037..cb34b99 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/batch/UpdateBatchTranslator.java
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.access.translator.batch;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.QuotingStrategy;
@@ -81,7 +81,7 @@ public class UpdateBatchTranslator extends DefaultBatchTranslator {
     }
 
     @Override
-    protected ParameterBinding[] createBindings() {
+    protected DbAttributeBinding[] createBindings() {
         UpdateBatchQuery updateBatch = (UpdateBatchQuery) query;
 
         List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes();
@@ -90,14 +90,14 @@ public class UpdateBatchTranslator extends DefaultBatchTranslator {
         int ul = updatedDbAttributes.size();
         int ql = qualifierAttributes.size();
 
-        ParameterBinding[] bindings = new ParameterBinding[ul + ql];
+        DbAttributeBinding[] bindings = new DbAttributeBinding[ul + ql];
 
         for (int i = 0; i < ul; i++) {
             DbAttribute a = updatedDbAttributes.get(i);
 
             String typeName = TypesMapping.getJavaBySqlType(a.getType());
             ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
-            bindings[i] = new ParameterBinding(a, extendedType);
+            bindings[i] = new DbAttributeBinding(a, extendedType);
         }
 
         for (int i = 0; i < ql; i++) {
@@ -105,14 +105,14 @@ public class UpdateBatchTranslator extends DefaultBatchTranslator {
 
             String typeName = TypesMapping.getJavaBySqlType(a.getType());
             ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
-            bindings[ul + i] = new ParameterBinding(a, extendedType);
+            bindings[ul + i] = new DbAttributeBinding(a, extendedType);
         }
 
         return bindings;
     }
 
     @Override
-    protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+    protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
 
         UpdateBatchQuery updateBatch = (UpdateBatchQuery) query;
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 f6021f2..7a4d9fd 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
@@ -1,25 +1,26 @@
 /*****************************************************************
- *   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.access.translator.procedure;
 
 import org.apache.cayenne.access.translator.ProcedureParameterBinding;
+import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.log.JdbcEventLogger;
 import org.apache.cayenne.log.NoopJdbcEventLogger;
@@ -40,215 +41,213 @@ import java.util.Map;
  */
 public class ProcedureTranslator {
 
-    /**
-     * Helper class to make OUT and VOID parameters logger-friendly.
-     */
-    static class NotInParam {
-
-        protected String type;
-
-        public NotInParam(String type) {
-            this.type = type;
-        }
-
-        @Override
-        public String toString() {
-            return type;
-        }
-    }
-
-    private static NotInParam OUT_PARAM = new NotInParam("[OUT]");
-
-    protected ProcedureQuery query;
-    protected Connection connection;
-    protected DbAdapter adapter;
-    protected EntityResolver entityResolver;
-    protected List<ProcedureParameter> callParams;
-    protected List<Object> values;
-    protected JdbcEventLogger logger;
-
-    public ProcedureTranslator() {
-        this.logger = NoopJdbcEventLogger.getInstance();
-    }
-
-    public void setQuery(ProcedureQuery query) {
-        this.query = query;
-    }
-
-    public void setConnection(Connection connection) {
-        this.connection = connection;
-    }
-
-    public void setAdapter(DbAdapter adapter) {
-        this.adapter = adapter;
-    }
-
-    /**
-     * @since 3.1
-     */
-    public void setJdbcEventLogger(JdbcEventLogger logger) {
-        this.logger = logger;
-    }
-
-    /**
-     * @since 3.1
-     */
-    public JdbcEventLogger getJdbcEventLogger() {
-        return logger;
-    }
-
-    /**
-     * @since 1.2
-     */
-    public void setEntityResolver(EntityResolver entityResolver) {
-        this.entityResolver = entityResolver;
-    }
-
-    /**
-     * Creates an SQL String for the stored procedure call.
-     */
-    protected String createSqlString() {
-        Procedure procedure = getProcedure();
-
-        StringBuilder buf = new StringBuilder();
-
-        int totalParams = callParams.size();
-
-        // check if procedure returns values
-        if (procedure.isReturningValue()) {
-            totalParams--;
-            buf.append("{? = call ");
-        }
-        else {
-            buf.append("{call ");
-        }
-
-        buf.append(procedure.getFullyQualifiedName());
-
-        if (totalParams > 0) {
-            // unroll the loop
-            buf.append("(?");
-
-            for (int i = 1; i < totalParams; i++) {
-                buf.append(", ?");
-            }
-
-            buf.append(")");
-        }
-
-        buf.append("}");
-        return buf.toString();
-    }
-
-    /**
-     * Creates and binds a PreparedStatement to execute query SQL via JDBC.
-     */
-    public PreparedStatement createStatement() throws Exception {
-        long t1 = System.currentTimeMillis();
-
-        this.callParams = getProcedure().getCallParameters();
-        this.values = new ArrayList<Object>(callParams.size());
-
-        initValues();
-        String sqlStr = createSqlString();
-
-        if (logger.isLoggable()) {
-            // need to convert OUT/VOID parameters to loggable strings
-            long time = System.currentTimeMillis() - t1;
-
-            List<Object> loggableParameters = new ArrayList<Object>(values.size());
-            for (Object val : values) {
-                if (val instanceof NotInParam) {
-                    val = val.toString();
-                }
-                loggableParameters.add(val);
-            }
-
-            // FIXME: compute proper attributes via callParams
-            logger.logQuery(sqlStr, null, loggableParameters, time);
-        }
-        CallableStatement stmt = connection.prepareCall(sqlStr);
-        initStatement(stmt);
-        return stmt;
-    }
-
-    public Procedure getProcedure() {
-        return query.getMetaData(entityResolver).getProcedure();
-    }
-
-    public ProcedureQuery getProcedureQuery() {
-        return query;
-    }
-
-    /**
-     * Set IN and OUT parameters.
-     */
-    protected void initStatement(CallableStatement stmt) throws Exception {
-        if (values != null && values.size() > 0) {
-            List<ProcedureParameter> params = getProcedure().getCallParameters();
-
-            int len = values.size();
-            for (int i = 0; i < len; i++) {
-                ProcedureParameter param = params.get(i);
-
-                // !Stored procedure parameter can be both in and out
-                // at the same time
-                if (param.isOutParam()) {
-                    setOutParam(stmt, param, i + 1);
-                }
-
-                if (param.isInParameter()) {
-                    setInParam(stmt, param, values.get(i), i + 1);
-                }
-            }
-        }
-    }
-
-    protected void initValues() {
-        Map<String, ?> queryValues = getProcedureQuery().getParameters();
-
-        // match values with parameters in the correct order.
-        // make an assumption that a missing value is NULL
-        // Any reason why this is bad?
-
-        for (ProcedureParameter param : callParams) {
-
-            if (param.getDirection() == ProcedureParameter.OUT_PARAMETER) {
-                values.add(OUT_PARAM);
-            }
-            else {
-                values.add(queryValues.get(param.getName()));
-            }
-        }
-    }
-
-    /**
-     * Sets a single IN parameter of the CallableStatement.
-     */
-    protected void setInParam(
-            CallableStatement stmt,
-            ProcedureParameter param,
-            Object val,
-            int pos) throws Exception {
-
-        ProcedureParameterBinding binding = new ProcedureParameterBinding(param);
-        binding.setValue(val);
-        binding.setStatementPosition(pos);
-        adapter.bindParameter(stmt, binding);
-    }
-
-    /**
-     * Sets a single OUT parameter of the CallableStatement.
-     */
-    protected void setOutParam(CallableStatement stmt, ProcedureParameter param, int pos)
-            throws Exception {
-
-        int precision = param.getPrecision();
-        if (precision >= 0) {
-            stmt.registerOutParameter(pos, param.getType(), precision);
-        }
-        else {
-            stmt.registerOutParameter(pos, param.getType());
-        }
-    }
+	/**
+	 * Helper class to make OUT and VOID parameters logger-friendly.
+	 */
+	static class NotInParam {
+
+		protected String type;
+
+		public NotInParam(String type) {
+			this.type = type;
+		}
+
+		@Override
+		public String toString() {
+			return type;
+		}
+	}
+
+	private static NotInParam OUT_PARAM = new NotInParam("[OUT]");
+
+	protected ProcedureQuery query;
+	protected Connection connection;
+	protected DbAdapter adapter;
+	protected EntityResolver entityResolver;
+	protected List<ProcedureParameter> callParams;
+	protected List<Object> values;
+	protected JdbcEventLogger logger;
+
+	public ProcedureTranslator() {
+		this.logger = NoopJdbcEventLogger.getInstance();
+	}
+
+	public void setQuery(ProcedureQuery query) {
+		this.query = query;
+	}
+
+	public void setConnection(Connection connection) {
+		this.connection = connection;
+	}
+
+	public void setAdapter(DbAdapter adapter) {
+		this.adapter = adapter;
+	}
+
+	/**
+	 * @since 3.1
+	 */
+	public void setJdbcEventLogger(JdbcEventLogger logger) {
+		this.logger = logger;
+	}
+
+	/**
+	 * @since 3.1
+	 */
+	public JdbcEventLogger getJdbcEventLogger() {
+		return logger;
+	}
+
+	/**
+	 * @since 1.2
+	 */
+	public void setEntityResolver(EntityResolver entityResolver) {
+		this.entityResolver = entityResolver;
+	}
+
+	/**
+	 * Creates an SQL String for the stored procedure call.
+	 */
+	protected String createSqlString() {
+		Procedure procedure = getProcedure();
+
+		StringBuilder buf = new StringBuilder();
+
+		int totalParams = callParams.size();
+
+		// check if procedure returns values
+		if (procedure.isReturningValue()) {
+			totalParams--;
+			buf.append("{? = call ");
+		} else {
+			buf.append("{call ");
+		}
+
+		buf.append(procedure.getFullyQualifiedName());
+
+		if (totalParams > 0) {
+			// unroll the loop
+			buf.append("(?");
+
+			for (int i = 1; i < totalParams; i++) {
+				buf.append(", ?");
+			}
+
+			buf.append(")");
+		}
+
+		buf.append("}");
+		return buf.toString();
+	}
+
+	/**
+	 * Creates and binds a PreparedStatement to execute query SQL via JDBC.
+	 */
+	public PreparedStatement createStatement() throws Exception {
+		long t1 = System.currentTimeMillis();
+
+		this.callParams = getProcedure().getCallParameters();
+		this.values = new ArrayList<Object>(callParams.size());
+
+		initValues();
+		String sqlStr = createSqlString();
+
+		if (logger.isLoggable()) {
+			// need to convert OUT/VOID parameters to loggable strings
+			long time = System.currentTimeMillis() - t1;
+
+			List<Object> loggableParameters = new ArrayList<Object>(values.size());
+			for (Object val : values) {
+				if (val instanceof NotInParam) {
+					val = val.toString();
+				}
+				loggableParameters.add(val);
+			}
+
+			// FIXME: compute proper attributes via callParams
+			logger.logQuery(sqlStr, null, loggableParameters, time);
+		}
+		CallableStatement stmt = connection.prepareCall(sqlStr);
+		initStatement(stmt);
+		return stmt;
+	}
+
+	public Procedure getProcedure() {
+		return query.getMetaData(entityResolver).getProcedure();
+	}
+
+	public ProcedureQuery getProcedureQuery() {
+		return query;
+	}
+
+	/**
+	 * Set IN and OUT parameters.
+	 */
+	protected void initStatement(CallableStatement stmt) throws Exception {
+		if (values != null && values.size() > 0) {
+			List<ProcedureParameter> params = getProcedure().getCallParameters();
+
+			int len = values.size();
+			for (int i = 0; i < len; i++) {
+				ProcedureParameter param = params.get(i);
+
+				// !Stored procedure parameter can be both in and out
+				// at the same time
+				if (param.isOutParam()) {
+					setOutParam(stmt, param, i + 1);
+				}
+
+				if (param.isInParameter()) {
+					setInParam(stmt, param, values.get(i), i + 1);
+				}
+			}
+		}
+	}
+
+	protected void initValues() {
+		Map<String, ?> queryValues = getProcedureQuery().getParameters();
+
+		// match values with parameters in the correct order.
+		// make an assumption that a missing value is NULL
+		// Any reason why this is bad?
+
+		for (ProcedureParameter param : callParams) {
+
+			if (param.getDirection() == ProcedureParameter.OUT_PARAMETER) {
+				values.add(OUT_PARAM);
+			} else {
+				values.add(queryValues.get(param.getName()));
+			}
+		}
+	}
+
+	/**
+	 * Sets a single IN parameter of the CallableStatement.
+	 */
+	protected void setInParam(
+			CallableStatement stmt,
+			ProcedureParameter param,
+			Object val,
+			int pos) throws Exception {
+		ExtendedType extendedType = adapter.getExtendedTypes().getDefaultType();
+		if (val != null) adapter.getExtendedTypes().getRegisteredType(val.getClass());
+		ProcedureParameterBinding binding = new ProcedureParameterBinding(param, extendedType);
+		binding.setValue(val);
+		binding.setStatementPosition(pos);
+		adapter.bindParameter(stmt, binding);
+	}
+
+	/**
+	 * Sets a single OUT parameter of the CallableStatement.
+	 */
+	protected void setOutParam(CallableStatement stmt, ProcedureParameter param, int pos)
+			throws Exception {
+
+		int precision = param.getPrecision();
+		if (precision >= 0) {
+			stmt.registerOutParameter(pos, param.getType(), precision);
+		} else {
+			stmt.registerOutParameter(pos, param.getType());
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/QueryAssembler.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/QueryAssembler.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/QueryAssembler.java
index 40554bd..03949c6 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/QueryAssembler.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/QueryAssembler.java
@@ -19,7 +19,7 @@
 
 package org.apache.cayenne.access.translator.select;
 
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.TypesMapping;
@@ -45,7 +45,7 @@ public abstract class QueryAssembler {
 	protected String sql;
 	protected DbAdapter adapter;
 	protected EntityResolver entityResolver;
-	protected List<ParameterBinding> bindings;
+	protected List<DbAttributeBinding> bindings;
 
 	/**
 	 * @since 4.0
@@ -55,7 +55,7 @@ public abstract class QueryAssembler {
 		this.adapter = adapter;
 		this.query = query;
 		this.queryMetadata = query.getMetaData(entityResolver);
-		this.bindings = new ArrayList<ParameterBinding>();
+		this.bindings = new ArrayList<DbAttributeBinding>();
 	}
 
 	/**
@@ -154,7 +154,7 @@ public abstract class QueryAssembler {
 		if (dbAttr != null) typeName = TypesMapping.getJavaBySqlType(dbAttr.getType());
 		ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
 		
-		ParameterBinding binding = new ParameterBinding(dbAttr, extendedType);
+		DbAttributeBinding binding = new DbAttributeBinding(dbAttr, extendedType);
 		binding.setValue(anObject);
 		binding.setStatementPosition(bindings.size() + 1);
 		bindings.add(binding);
@@ -163,7 +163,7 @@ public abstract class QueryAssembler {
 	/**
 	 * @since 4.0
 	 */
-	public ParameterBinding[] getBindings() {
-		return bindings.toArray(new ParameterBinding[bindings.size()]);
+	public DbAttributeBinding[] getBindings() {
+		return bindings.toArray(new DbAttributeBinding[bindings.size()]);
 	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/SelectTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/SelectTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/SelectTranslator.java
index d652885..6554565 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/SelectTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/translator/select/SelectTranslator.java
@@ -22,7 +22,7 @@ package org.apache.cayenne.access.translator.select;
 import java.util.Map;
 
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.query.SelectQuery;
 
@@ -35,7 +35,7 @@ public interface SelectTranslator {
 
 	String getSql() throws Exception;
 
-	ParameterBinding[] getBindings();
+	DbAttributeBinding[] getBindings();
 
 	Map<ObjAttribute, ColumnDescriptor> getAttributeOverrides();
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 8df16f1..f3fb80c 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
@@ -21,9 +21,7 @@ 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.Binding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
@@ -40,7 +38,6 @@ 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;
@@ -203,22 +200,12 @@ public class AutoAdapter implements DbAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, ParameterBinding parameterBinding)
+	public void bindParameter(PreparedStatement statement, Binding parameterBinding)
 			throws SQLException, Exception {
 		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
 	public String tableTypeForTable() {
 		return getAdapter().tableTypeForTable();
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 6cf4eb0..4fbaa3d 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
@@ -1,27 +1,25 @@
 /*****************************************************************
- *   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;
 
 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.Binding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
@@ -36,7 +34,6 @@ 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;
@@ -52,14 +49,14 @@ public interface DbAdapter {
 	/**
 	 * Returns a String used to terminate a batch in command-line tools. E.g.
 	 * ";" on Oracle or "go" on Sybase.
-	 * 
+	 *
 	 * @since 1.0.4
 	 */
 	String getBatchTerminator();
 
 	/**
 	 * Returns a SelectTranslator that works with the adapter target database.
-	 * 
+	 *
 	 * @since 4.0
 	 */
 	SelectTranslator getSelectTranslator(SelectQuery<?> query, EntityResolver entityResolver);
@@ -68,7 +65,7 @@ public interface DbAdapter {
 
 	/**
 	 * Returns an instance of SQLAction that should handle the query.
-	 * 
+	 *
 	 * @since 1.2
 	 */
 	SQLAction getAction(Query query, DataNode node);
@@ -91,7 +88,7 @@ public interface DbAdapter {
 	/**
 	 * Returns true if a target database supports key autogeneration. This
 	 * feature also requires JDBC3-compliant driver.
-	 * 
+	 *
 	 * @since 1.2
 	 */
 	boolean supportsGeneratedKeys();
@@ -105,7 +102,7 @@ public interface DbAdapter {
 
 	/**
 	 * Returns a collection of SQL statements needed to drop a database table.
-	 * 
+	 *
 	 * @since 3.0
 	 */
 	Collection<String> dropTableStatements(DbEntity table);
@@ -119,7 +116,7 @@ public interface DbAdapter {
 	/**
 	 * Returns a DDL string to create a unique constraint over a set of columns,
 	 * or null if the unique constraints are not supported.
-	 * 
+	 *
 	 * @since 1.1
 	 */
 	String createUniqueConstraint(DbEntity source, Collection<DbAttribute> columns);
@@ -150,7 +147,7 @@ public interface DbAdapter {
 	/**
 	 * Creates and returns a DbAttribute based on supplied parameters (usually
 	 * obtained from database meta data).
-	 * 
+	 *
 	 * @param name
 	 *            database column name
 	 * @param typeName
@@ -169,22 +166,9 @@ public interface DbAdapter {
 	DbAttribute buildAttribute(String name, String typeName, int type, int size, int scale, boolean allowNulls);
 
 	/**
-	 * Binds an object value to PreparedStatement's numbered parameter.
+	 * Binds an object value to PreparedStatement's parameter.
 	 */
-	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;
+	void bindParameter(PreparedStatement statement, Binding parameterBinding) throws SQLException, Exception;
 
 	/**
 	 * Returns the name of the table type (as returned by
@@ -206,7 +190,7 @@ public interface DbAdapter {
 	/**
 	 * Append the column type part of a "create table" to the given
 	 * {@link StringBuffer}
-	 * 
+	 *
 	 * @param sqlBuffer
 	 *            the {@link StringBuffer} to append the column type to
 	 * @param column
@@ -224,7 +208,7 @@ public interface DbAdapter {
 
 	/**
 	 * Returns SQL identifier quoting strategy object
-	 * 
+	 *
 	 * @since 4.0
 	 */
 	QuotingStrategy getQuotingStrategy();
@@ -232,14 +216,14 @@ public interface DbAdapter {
 	/**
 	 * Allows the users to get access to the adapter decorated by a given
 	 * adapter.
-	 * 
+	 *
 	 * @since 4.0
 	 */
 	DbAdapter unwrap();
 
 	/**
 	 * Returns a translator factory for EJBQL to SQL translation.
-	 * 
+	 *
 	 * @since 4.0
 	 */
 	EJBQLTranslatorFactory getEjbqlTranslatorFactory();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 773f069..4cf88eb 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,9 +21,7 @@ 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.Binding;
 import org.apache.cayenne.access.translator.batch.BatchTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory;
@@ -38,11 +36,7 @@ import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbJoin;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.*;
 import org.apache.cayenne.merge.MergerFactory;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
@@ -52,7 +46,6 @@ 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;
@@ -543,7 +536,7 @@ public class JdbcAdapter implements DbAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
+	public void bindParameter(PreparedStatement statement, Binding binding)
 			throws SQLException, Exception {
 
 		if (binding.getValue() == null) {
@@ -554,40 +547,11 @@ public class JdbcAdapter implements DbAdapter {
 					, 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());
-		}
-	}
-
-	@Override
 	public boolean supportsBatchUpdates() {
 		return this.supportsBatchUpdates;
 	}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 35efb99..d917a46 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,15 +21,10 @@ 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.Binding;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
-import org.apache.cayenne.access.types.BooleanType;
-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.JdbcAdapter;
@@ -234,9 +229,9 @@ public class DB2Adapter extends JdbcAdapter {
 
     @Override
     public void bindParameter(
-            PreparedStatement statement, ParameterBinding binding) throws SQLException, Exception {
+            PreparedStatement statement, Binding binding) throws SQLException, Exception {
 
-        if (binding.getValue() == null && (binding.getAttribute().getType() == 0 || binding.getAttribute().getType() == Types.BOOLEAN)) {
+        if (binding.getValue() == null && (binding.getType() == 0 || binding.getType() == Types.BOOLEAN)) {
             statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
         }
         else {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 c9c5a0d..05b7d3b 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,17 +20,12 @@
 package org.apache.cayenne.dba.derby;
 
 import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.Binding;
 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.types.ByteType;
-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.ShortType;
+import org.apache.cayenne.access.types.*;
 import org.apache.cayenne.configuration.Constants;
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.dba.JdbcAdapter;
@@ -192,9 +187,9 @@ public class DerbyAdapter extends JdbcAdapter {
     @Override
     public void bindParameter(
             PreparedStatement statement,
-            ParameterBinding binding) throws SQLException, Exception {
+            Binding binding) throws SQLException, Exception {
 
-        if (binding.getValue() == null && binding.getAttribute().getType() == 0) {
+        if (binding.getValue() == null && binding.getType() == 0) {
             statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
         } else {
             binding.setType(convertNTypes(binding.getType()));

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 5da2682..7605bcf 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
@@ -21,7 +21,7 @@ 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.Binding;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
 import org.apache.cayenne.access.translator.select.QueryAssembler;
 import org.apache.cayenne.access.translator.select.SelectTranslator;
@@ -110,10 +110,10 @@ public class IngresAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
+	public void bindParameter(PreparedStatement statement, Binding binding)
 			throws SQLException, Exception {
 
-		if (binding.getValue() == null && (binding.getAttribute().getType() == Types.BOOLEAN || binding.getAttribute().getType() == Types.BIT)) {
+		if (binding.getValue() == null && (binding.getType() == Types.BOOLEAN || binding.getType() == Types.BIT)) {
 			statement.setNull(binding.getStatementPosition(), Types.VARCHAR);
 		} else {
 			super.bindParameter(statement, binding);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 961f653..5bbb17b 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
@@ -21,7 +21,7 @@ package org.apache.cayenne.dba.mysql;
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.Binding;
 import org.apache.cayenne.access.translator.ejbql.EJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.ejbql.JdbcEJBQLTranslatorFactory;
 import org.apache.cayenne.access.translator.select.QualifierTranslator;
@@ -202,7 +202,7 @@ public class MySQLAdapter extends JdbcAdapter {
 	}
 
 	@Override
-	public void bindParameter(PreparedStatement statement, ParameterBinding binding)
+	public void bindParameter(PreparedStatement statement, Binding binding)
 			throws SQLException, Exception {
 		binding.setType(mapNTypes(binding.getType()));
 		super.bindParameter(statement, binding);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/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 3b0c829..8cfdc2c 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
@@ -22,7 +22,7 @@ package org.apache.cayenne.dba.oracle;
 import org.apache.cayenne.CayenneException;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.OperationObserver;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.log.JdbcEventLogger;
 import org.apache.cayenne.map.DbAttribute;
@@ -45,11 +45,11 @@ class Oracle8LOBBatchAction implements SQLAction {
 	private DbAdapter adapter;
 	private JdbcEventLogger logger;
 
-	private static void bind(DbAdapter adapter, PreparedStatement statement, ParameterBinding[] bindings)
+	private static void bind(DbAdapter adapter, PreparedStatement statement, DbAttributeBinding[] bindings)
 			throws SQLException, Exception {
 
-		for (ParameterBinding b : bindings) {
-			ParameterBinding binding = new ParameterBinding(b.getAttribute(), adapter.getExtendedTypes()
+		for (DbAttributeBinding b : bindings) {
+			DbAttributeBinding binding = new DbAttributeBinding(b.getAttribute(), adapter.getExtendedTypes()
 					.getRegisteredType(b.getValue().getClass()));
 			adapter.bindParameter(statement, binding);
 		}
@@ -97,7 +97,7 @@ class Oracle8LOBBatchAction implements SQLAction {
 
 			try (PreparedStatement statement = connection.prepareStatement(updateStr);) {
 
-				ParameterBinding[] bindings = translator.updateBindings(row);
+				DbAttributeBinding[] bindings = translator.updateBindings(row);
 				logger.logQueryParameters("bind", bindings);
 
 				bind(adapter, statement, bindings);
@@ -141,7 +141,7 @@ class Oracle8LOBBatchAction implements SQLAction {
 				Object value = qualifierValues.get(i);
 				DbAttribute attribute = qualifierAttributes.get(i);
 
-				ParameterBinding binding = new ParameterBinding(attribute, adapter.getExtendedTypes()
+				DbAttributeBinding binding = new DbAttributeBinding(attribute, adapter.getExtendedTypes()
 						.getRegisteredType(value.getClass()));
 				binding.setStatementPosition(i + 1);
 				binding.setValue(value);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/2d3f999b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java
index fb2deb7..d25d32f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java
@@ -20,7 +20,7 @@
 package org.apache.cayenne.dba.oracle;
 
 import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.access.translator.ParameterBinding;
+import org.apache.cayenne.access.translator.DbAttributeBinding;
 import org.apache.cayenne.access.translator.batch.DefaultBatchTranslator;
 import org.apache.cayenne.access.types.ExtendedType;
 import org.apache.cayenne.dba.DbAdapter;
@@ -111,31 +111,31 @@ abstract class Oracle8LOBBatchTranslator extends DefaultBatchTranslator {
     }
     
     @Override
-    protected ParameterBinding[] createBindings() {
+    protected DbAttributeBinding[] createBindings() {
         List<DbAttribute> dbAttributes = query.getDbAttributes();
         int len = dbAttributes.size();
 
-        ParameterBinding[] bindings = new ParameterBinding[len];
+        DbAttributeBinding[] bindings = new DbAttributeBinding[len];
 
         for (int i = 0; i < len; i++) {
             DbAttribute attribute = dbAttributes.get(i);
 
             String typeName = TypesMapping.getJavaBySqlType(attribute.getType());
             ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
-            bindings[i] = new ParameterBinding(attribute, extendedType);
+            bindings[i] = new DbAttributeBinding(attribute, extendedType);
         }
 
         return bindings;
     }
     
     @Override
-    protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) {
+    protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
 
         int len = bindings.length;
 
         for (int i = 0, j = 1; i < len; i++) {
 
-            ParameterBinding b = bindings[i];
+            DbAttributeBinding b = bindings[i];
 
             Object value = row.getValue(i);
             DbAttribute attribute = b.getAttribute();


Mime
View raw message