You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2017/10/25 20:40:16 UTC
[geode] branch feature/GEODE-3781 updated: more
getColumnToValueList work
This is an automated email from the ASF dual-hosted git repository.
dschneider pushed a commit to branch feature/GEODE-3781
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-3781 by this push:
new 0ff46e6 more getColumnToValueList work
0ff46e6 is described below
commit 0ff46e662d6c247e048868ba165ba50111d36617
Author: Darrel Schneider <ds...@pivotal.io>
AuthorDate: Wed Oct 25 13:40:05 2017 -0700
more getColumnToValueList work
---
.../apache/geode/connectors/jdbc/JDBCManager.java | 25 +++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java
index fb53710..67fdc1f 100644
--- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java
+++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java
@@ -19,6 +19,7 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -135,8 +136,18 @@ public class JDBCManager {
private List<ColumnValue> getColumnToValueList(String tableName, Object key, PdxInstance value,
Operation operation) {
Set<String> keyColumnNames = getKeyColumnNames(tableName);
- for (String fieldName : value.getFieldNames()) {
+ List<String> fieldNames = value.getFieldNames();
+ List<ColumnValue> result = new ArrayList<>(fieldNames.size()+1);
+ for (String fieldName : fieldNames) {
String columnName = mapFieldNameToColumnName(fieldName, tableName);
+ if (columnName == null) {
+ // this field is not mapped to a column
+ if (isFieldExcluded(fieldName)) {
+ continue;
+ } else {
+ throw new IllegalStateException("No column on table " + tableName + " was found for the field named " + fieldName);
+ }
+ }
boolean isKey = keyColumnNames.contains(columnName);
if (operation.isDestroy() && !isKey) {
@@ -145,8 +156,15 @@ public class JDBCManager {
// TODO: what if isKey and columnValue needs to be the key object instead of from PdxInstance?
Object columnValue = value.getField(fieldName);
ColumnValue cv = new ColumnValue(isKey, fieldName, columnValue);
+ // TODO: any need to order the items in the list?
+ result.add(cv);
}
- return null;
+ return result;
+ }
+
+ private boolean isFieldExcluded(String fieldName) {
+ // TODO Auto-generated method stub
+ return false;
}
private String mapFieldNameToColumnName(String fieldName, String tableName) {
@@ -163,7 +181,4 @@ public class JDBCManager {
// TODO: check config for mapping
return region.getName();
}
-
-
-
}
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].