cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-2050 Refactoring: ParameterBinding to contain ExtendedType property
Date Sun, 06 Mar 2016 00:06:21 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 08fbf1e08 -> 6ad05a090


CAY-2050 Refactoring: ParameterBinding to contain ExtendedType property

* missing ExtendedType assignment
* preventing double lookup of ExtendedType


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

Branch: refs/heads/master
Commit: 6ad05a09051ea710546d413b86b24d90e9ad7bd2
Parents: 08fbf1e
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Sat Mar 5 03:31:36 2016 -0800
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sat Mar 5 03:33:51 2016 -0800

----------------------------------------------------------------------
 .../apache/cayenne/access/jdbc/SQLTemplateAction.java    | 11 ++++++-----
 .../access/translator/procedure/ProcedureTranslator.java |  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/6ad05a09/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 e24806c..876c77e 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
@@ -351,15 +351,16 @@ public class SQLTemplateAction implements SQLAction {
 		if (bindings.length > 0) {
 			int len = bindings.length;
 			for (int i = 0; i < len; i++) {
-				ExtendedType extendedType = getAdapter().getExtendedTypes().getDefaultType();
-				if (bindings[i].getValue() != null) {
-					extendedType = getAdapter().getExtendedTypes().getRegisteredType(bindings[i].getValue().getClass());
-				}
+
+				Object value = bindings[i].getValue();
+				ExtendedType extendedType = value != null
+						? getAdapter().getExtendedTypes().getRegisteredType(value.getClass())
+						: getAdapter().getExtendedTypes().getDefaultType();
 
 				ParameterBinding binding = new ParameterBinding(extendedType);
 				binding.setType(bindings[i].getJdbcType());
 				binding.setStatementPosition(i + 1);
-				binding.setValue(bindings[i].getValue());
+				binding.setValue(value);
 				dataNode.getAdapter().bindParameter(preparedStatement, binding);
 			}
 		}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/6ad05a09/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 7a4d9fd..c5c04f9 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
@@ -229,8 +229,8 @@ public class ProcedureTranslator {
 			ProcedureParameter param,
 			Object val,
 			int pos) throws Exception {
-		ExtendedType extendedType = adapter.getExtendedTypes().getDefaultType();
-		if (val != null) adapter.getExtendedTypes().getRegisteredType(val.getClass());
+		ExtendedType extendedType = val != null ? adapter.getExtendedTypes().getRegisteredType(val.getClass())
+				: adapter.getExtendedTypes().getDefaultType();
 		ProcedureParameterBinding binding = new ProcedureParameterBinding(param, extendedType);
 		binding.setValue(val);
 		binding.setStatementPosition(pos);


Mime
View raw message