ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [42/50] [abbrv] incubator-ignite git commit: # ignite-32 get column value by index from result set.
Date Thu, 05 Feb 2015 08:46:15 GMT
# ignite-32 get column value by index from result set.


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

Branch: refs/heads/ignite-128
Commit: ffd877d38ea467b258969988600c40422e4b208b
Parents: f087f81
Author: anovikov <anovikov@gridgain.com>
Authored: Thu Feb 5 12:51:20 2015 +0700
Committer: anovikov <anovikov@gridgain.com>
Committed: Thu Feb 5 12:51:20 2015 +0700

----------------------------------------------------------------------
 .../ignite/cache/store/jdbc/JdbcCacheStore.java | 141 ++++++++++++++-----
 .../cache/store/jdbc/JdbcPojoCacheStore.java    |  56 ++------
 .../store/jdbc/dialect/BasicJdbcDialect.java    |  32 ++---
 .../cache/store/jdbc/dialect/DB2Dialect.java    |   6 +-
 .../cache/store/jdbc/dialect/H2Dialect.java     |   4 +-
 .../cache/store/jdbc/dialect/JdbcDialect.java   |  40 +++---
 .../cache/store/jdbc/dialect/MySQLDialect.java  |   4 +-
 .../cache/store/jdbc/dialect/OracleDialect.java |   6 +-
 .../store/jdbc/dialect/SQLServerDialect.java    |   6 +-
 9 files changed, 155 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcCacheStore.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcCacheStore.java
index 29ca25d..255b895 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcCacheStore.java
@@ -88,6 +88,9 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
     /** Connection attribute property name. */
     protected static final String ATTR_CONN_PROP = "JDBC_STORE_CONNECTION";
 
+    /** Empty column value. */
+    protected static final Object[] EMPTY_COLUMN_VALUE = new Object[] { null };
+
     /** Auto-injected logger instance. */
     @IgniteLoggerResource
     protected IgniteLogger log;
@@ -131,11 +134,12 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
      * @param <R> Type of result object.
      * @param typeName Type name.
      * @param fields Fields descriptors.
+     * @param loadColIdxs Select query columns index.
      * @param rs ResultSet.
      * @return Constructed object.
      */
-    protected abstract <R> R buildObject(String typeName, Collection<CacheTypeFieldMetadata>
fields, ResultSet rs)
-        throws CacheLoaderException;
+    protected abstract <R> R buildObject(String typeName, Collection<CacheTypeFieldMetadata>
fields,
+        Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException;
 
     /**
      * Extract key type id from key object.
@@ -316,15 +320,67 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
     }
 
     /**
+     * Retrieves the value of the designated column in the current row of this <code>ResultSet</code>
object and
+     * will convert to the requested Java data type.
+     *
+     * @param rs Result set.
+     * @param colIdx Column index in result set.
+     * @param type Class representing the Java data type to convert the designated column
to.
+     * @return Value in column.
+     * @throws SQLException If a database access error occurs or this method is called.
+     */
+    protected Object getColumnValue(ResultSet rs, int colIdx, Class<?> type) throws
SQLException {
+        if (type == boolean.class)
+            return rs.getBoolean(colIdx);
+        if (type == int.class)
+            return rs.getInt(colIdx);
+        else if (type == long.class)
+            return rs.getLong(colIdx);
+        else if (type == double.class)
+            return rs.getDouble(colIdx);
+        else if (type == byte.class)
+            return rs.getByte(colIdx);
+        else if (type == short.class)
+            return rs.getShort(colIdx);
+        else if (type == float.class)
+            return rs.getFloat(colIdx);
+        else if (type == Integer.class || type == Long.class || type == Double.class ||
+            type == Byte.class || type == Short.class ||  type == Float.class) {
+            Object val = rs.getObject(colIdx);
+
+            if (val != null) {
+                Number num = (Number)val;
+
+                if (type == Integer.class)
+                    return num.intValue();
+                else if (type == Long.class)
+                    return num.longValue();
+                else if (type == Double.class)
+                    return num.doubleValue();
+                else if (type == Byte.class)
+                    return num.byteValue();
+                else if (type == Short.class)
+                    return num.shortValue();
+                else if (type == Float.class)
+                    return num.floatValue();
+            }
+            else
+                return EMPTY_COLUMN_VALUE;
+        }
+
+        return rs.getObject(colIdx);
+    }
+
+    /**
      * Construct load cache from range.
      *
-     * @param m Type mapping description.
+     * @param em Type mapping description.
      * @param clo Closure that will be applied to loaded values.
      * @param lowerBound Lower bound for range.
      * @param upperBound Upper bound for range.
      * @return Callable for pool submit.
      */
-    private Callable<Void> loadCacheRange(final EntryMapping m, final IgniteBiInClosure<K,
V> clo,
+    private Callable<Void> loadCacheRange(final EntryMapping em, final IgniteBiInClosure<K,
V> clo,
         @Nullable final Object[] lowerBound, @Nullable final Object[] upperBound) {
         return new Callable<Void>() {
             @Override public Void call() throws Exception {
@@ -336,8 +392,8 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
                     conn = openConnection(true);
 
                     stmt = conn.prepareStatement(lowerBound == null && upperBound
== null
-                        ? m.loadCacheQry
-                        : m.loadCacheRangeQuery(lowerBound != null, upperBound != null));
+                        ? em.loadCacheQry
+                        : em.loadCacheRangeQuery(lowerBound != null, upperBound != null));
 
                     int ix = 1;
 
@@ -354,8 +410,8 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
                     ResultSet rs = stmt.executeQuery();
 
                     while (rs.next()) {
-                        K key = buildObject(m.keyType(), m.keyColumns(), rs);
-                        V val = buildObject(m.valueType(), m.valueColumns(), rs);
+                        K key = buildObject(em.keyType(), em.keyColumns(), em.loadColIdxs,
rs);
+                        V val = buildObject(em.valueType(), em.valueColumns(), em.loadColIdxs,
rs);
 
                         clo.apply(key, val);
                     }
@@ -557,7 +613,7 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
             ResultSet rs = stmt.executeQuery();
 
             if (rs.next())
-                return buildObject(em.valueType(), em.valueColumns(), rs);
+                return buildObject(em.valueType(), em.valueColumns(), em.loadColIdxs, rs);
         }
         catch (SQLException e) {
             throw new CacheLoaderException("Failed to load object [table=" + em.fullTableName()
+
@@ -1197,6 +1253,9 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
         /** Database unique value columns. */
         private final Collection<String> cols;
 
+        /** Select query columns index. */
+        private final Map<String, Integer> loadColIdxs;
+
         /** Unique value fields. */
         private final Collection<CacheTypeFieldMetadata> uniqValFields;
 
@@ -1228,33 +1287,38 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
 
             String tblName = typeMeta.getDatabaseTable();
 
-            fullTblName = schema + "." + tblName;
+            fullTblName = F.isEmpty(schema) ? tblName : schema + "." + tblName;
 
             keyCols = databaseColumns(keyFields);
 
-            Collection<String> valCols = databaseColumns(valFields);
-
             Collection<String> uniqValCols = databaseColumns(uniqValFields);
 
             cols = F.concat(false, keyCols, uniqValCols);
 
-            loadCacheQry = dialect.loadCacheQuery(schema, tblName, cols);
+            loadColIdxs = U.newHashMap(cols.size());
+
+            int idx = 1;
+
+            for (String col : cols)
+                loadColIdxs.put(col, idx++);
+
+            loadCacheQry = dialect.loadCacheQuery(fullTblName, cols);
 
-            loadCacheSelRangeQry = dialect.loadCacheSelectRangeQuery(schema, tblName, keyCols);
+            loadCacheSelRangeQry = dialect.loadCacheSelectRangeQuery(fullTblName, keyCols);
 
-            loadQrySingle = dialect.loadQuery(schema, tblName, keyCols, valCols, 1);
+            loadQrySingle = dialect.loadQuery(fullTblName, keyCols, cols, 1);
 
             maxKeysPerStmt = dialect.getMaxParamsCnt() / keyCols.size();
 
-            loadQry = dialect.loadQuery(schema, tblName, keyCols, uniqValCols, maxKeysPerStmt);
+            loadQry = dialect.loadQuery(fullTblName, keyCols, cols, maxKeysPerStmt);
 
-            insQry = dialect.insertQuery(schema, tblName, keyCols, uniqValCols);
+            insQry = dialect.insertQuery(fullTblName, keyCols, uniqValCols);
 
-            updQry = dialect.updateQuery(schema, tblName, keyCols, uniqValCols);
+            updQry = dialect.updateQuery(fullTblName, keyCols, uniqValCols);
 
-            mergeQry = dialect.mergeQuery(schema, tblName, keyCols, uniqValCols);
+            mergeQry = dialect.mergeQuery(fullTblName, keyCols, uniqValCols);
 
-            remQry = dialect.removeQuery(schema, tblName, keyCols);
+            remQry = dialect.removeQuery(fullTblName, keyCols);
         }
 
         /**
@@ -1285,7 +1349,7 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
             if (keyCnt == 1)
                 return loadQrySingle;
 
-            return dialect.loadQuery(typeMeta.getDatabaseSchema(), typeMeta.getDatabaseTable(),
keyCols, cols, keyCnt);
+            return dialect.loadQuery(fullTblName, keyCols, cols, keyCnt);
         }
 
         /**
@@ -1296,8 +1360,7 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
          * @return Query with range.
          */
         protected String loadCacheRangeQuery(boolean appendLowerBound, boolean appendUpperBound)
{
-            return dialect.loadCacheRangeQuery(typeMeta.getDatabaseSchema(), typeMeta.getDatabaseTable(),
keyCols, cols,
-                appendLowerBound, appendUpperBound);
+            return dialect.loadCacheRangeQuery(fullTblName, keyCols, cols, appendLowerBound,
appendUpperBound);
         }
 
         /** Key type. */
@@ -1346,7 +1409,7 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
      */
     private class LoadCacheCustomQueryWorker<K1, V1> implements Callable<Void>
{
         /** Entry mapping description. */
-        private final EntryMapping m;
+        private final EntryMapping em;
 
         /** User query. */
         private final String qry;
@@ -1355,12 +1418,12 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
         private final IgniteBiInClosure<K1, V1> clo;
 
         /**
-         * @param m Entry mapping description.
+         * @param em Entry mapping description.
          * @param qry User query.
          * @param clo Closure for loaded values.
          */
-        private LoadCacheCustomQueryWorker(EntryMapping m, String qry, IgniteBiInClosure<K1,
V1> clo) {
-            this.m = m;
+        private LoadCacheCustomQueryWorker(EntryMapping em, String qry, IgniteBiInClosure<K1,
V1> clo) {
+            this.em = em;
             this.qry = qry;
             this.clo = clo;
         }
@@ -1379,8 +1442,8 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
                 ResultSet rs = stmt.executeQuery();
 
                 while (rs.next()) {
-                    K1 key = buildObject(m.keyType(), m.keyColumns(), rs);
-                    V1 val = buildObject(m.valueType(), m.valueColumns(), rs);
+                    K1 key = buildObject(em.keyType(), em.keyColumns(), em.loadColIdxs, rs);
+                    V1 val = buildObject(em.valueType(), em.valueColumns(), em.loadColIdxs,
rs);
 
                     clo.apply(key, val);
                 }
@@ -1437,17 +1500,17 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
         private final Collection<K1> keys;
 
         /** Entry mapping description. */
-        private final EntryMapping m;
+        private final EntryMapping em;
 
         /**
          * @param conn Connection.
-         * @param m Entry mapping description.
+         * @param em Entry mapping description.
          */
-        private LoadWorker(Connection conn, EntryMapping m) {
+        private LoadWorker(Connection conn, EntryMapping em) {
             this.conn = conn;
-            this.m = m;
+            this.em = em;
 
-            keys = new ArrayList<>(m.maxKeysPerStmt);
+            keys = new ArrayList<>(em.maxKeysPerStmt);
         }
 
         /** {@inheritDoc} */
@@ -1455,13 +1518,13 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
             PreparedStatement stmt = null;
 
             try {
-                stmt = conn.prepareStatement(m.loadQuery(keys.size()));
+                stmt = conn.prepareStatement(em.loadQuery(keys.size()));
 
                 int i = 1;
 
                 for (Object key : keys)
-                    for (CacheTypeFieldMetadata field : m.keyColumns()) {
-                        Object fieldVal = extractField(m.keyType(), field.getJavaName(),
key);
+                    for (CacheTypeFieldMetadata field : em.keyColumns()) {
+                        Object fieldVal = extractField(em.keyType(), field.getJavaName(),
key);
 
                         if (fieldVal != null)
                             stmt.setObject(i++, fieldVal);
@@ -1474,8 +1537,8 @@ public abstract class JdbcCacheStore<K, V> extends CacheStore<K,
V> implements L
                 Map<K1, V1> entries = U.newHashMap(keys.size());
 
                 while (rs.next()) {
-                    K1 key = buildObject(m.keyType(), m.keyColumns(), rs);
-                    V1 val = buildObject(m.valueType(), m.valueColumns(), rs);
+                    K1 key = buildObject(em.keyType(), em.keyColumns(), em.loadColIdxs, rs);
+                    V1 val = buildObject(em.valueType(), em.valueColumns(), em.loadColIdxs,
rs);
 
                     entries.put(key, val);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcPojoCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcPojoCacheStore.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcPojoCacheStore.java
index 45f8dd9..e80fa62 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcPojoCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/JdbcPojoCacheStore.java
@@ -154,58 +154,18 @@ public class JdbcPojoCacheStore extends JdbcCacheStore<Object, Object>
{
 
     /** {@inheritDoc} */
     @Override protected <R> R buildObject(String typeName, Collection<CacheTypeFieldMetadata>
fields,
-        ResultSet rs) throws CacheLoaderException {
-        PojoMethodsCache t = mtdsCache.get(session().cacheName()).get(typeName);
+        Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException
{
+        PojoMethodsCache mc = mtdsCache.get(session().cacheName()).get(typeName);
 
-        Object obj = t.newInstance();
+        Object obj = mc.newInstance();
 
         try {
             for (CacheTypeFieldMetadata field : fields) {
-                Method setter = t.setters.get(field.getJavaName());
-
-                Class<?> type = field.getJavaType();
-
-                String colName = field.getDatabaseName();
-
-                if (type == boolean.class)
-                    setter.invoke(obj, rs.getBoolean(colName));
-                else if (type == byte.class)
-                    setter.invoke(obj, rs.getByte(colName));
-                else if (type == short.class)
-                    setter.invoke(obj, rs.getShort(colName));
-                else if (type == int.class)
-                    setter.invoke(obj, rs.getInt(colName));
-                else if (type == long.class)
-                    setter.invoke(obj, rs.getLong(colName));
-                else if (type == float.class)
-                    setter.invoke(obj, rs.getFloat(colName));
-                else if (type == double.class)
-                    setter.invoke(obj, rs.getDouble(colName));
-                else if (type == Byte.class || type == Short.class || type == Integer.class
||
-                    type == Long.class || type == Float.class || type == Double.class) {
-                    Object val = rs.getObject(colName);
-
-                    if (val != null) {
-                        Number num = (Number)val;
-
-                        if (type == Byte.class)
-                            setter.invoke(obj, num.byteValue());
-                        else if (type == Short.class)
-                            setter.invoke(obj, num.shortValue());
-                        else if (type == Integer.class)
-                            setter.invoke(obj, num.intValue());
-                        else if (type == long.class)
-                            setter.invoke(obj, num.longValue());
-                        else if (type == float.class)
-                            setter.invoke(obj, num.floatValue());
-                        else if (type == double.class)
-                            setter.invoke(obj, num.doubleValue());
-                    }
-                    else
-                        setter.invoke(obj, new Object[]{ null });
-                }
-                else
-                    setter.invoke(obj, rs.getObject(colName));
+                Method setter = mc.setters.get(field.getJavaName());
+
+                Integer colIdx = loadColIdxs.get(field.getDatabaseName());
+
+                setter.invoke(obj, getColumnValue(rs, colIdx, field.getJavaType()));
             }
 
             return (R)obj;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
index da54b7c..4910025 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
@@ -146,15 +146,15 @@ public class BasicJdbcDialect implements JdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String loadCacheSelectRangeQuery(String schema, String tblName, Collection<String>
keyCols) {
+    @Override public String loadCacheSelectRangeQuery(String fullTblName, Collection<String>
keyCols) {
         String cols = mkString(keyCols, ",");
 
-        return String.format("SELECT %s FROM (SELECT %s, ROWNUM() AS rn FROM %s.%s ORDER
BY %s) WHERE mod(rn, ?) = 0",
-            cols, cols, schema, tblName, cols);
+        return String.format("SELECT %s FROM (SELECT %s, ROWNUM() AS rn FROM %s ORDER BY
%s) WHERE mod(rn, ?) = 0",
+            cols, cols, fullTblName, cols);
     }
 
     /** {@inheritDoc} */
-    @Override public String loadCacheRangeQuery(String schema, String tblName,
+    @Override public String loadCacheRangeQuery(String fullTblName,
         Collection<String> keyCols, Iterable<String> uniqCols, boolean appendLowerBound,
boolean appendUpperBound) {
         assert appendLowerBound || appendUpperBound;
 
@@ -197,35 +197,35 @@ public class BasicJdbcDialect implements JdbcDialect {
             sb.a(")");
         }
 
-        return String.format("SELECT %s FROM %s.%s WHERE %s", mkString(uniqCols, ","), schema,
tblName, sb.toString());
+        return String.format("SELECT %s FROM %s WHERE %s", mkString(uniqCols, ","), fullTblName,
sb.toString());
     }
 
     /** {@inheritDoc} */
-    @Override public String loadCacheQuery(String schema, String tblName, Iterable<String>
uniqCols) {
-        return String.format("SELECT %s FROM %s.%s", mkString(uniqCols, ","), schema, tblName);
+    @Override public String loadCacheQuery(String fullTblName, Iterable<String> uniqCols)
{
+        return String.format("SELECT %s FROM %s", mkString(uniqCols, ","), fullTblName);
     }
 
     /** {@inheritDoc} */
-    @Override public String loadQuery(String schema, String tblName, Collection<String>
keyCols, Iterable<String> cols,
+    @Override public String loadQuery(String fullTblName, Collection<String> keyCols,
Iterable<String> cols,
         int keyCnt) {
         assert !keyCols.isEmpty();
 
         String params = where(keyCols, keyCnt);
 
-        return String.format("SELECT %s FROM %s.%s WHERE %s", mkString(cols, ","), schema,
tblName, params);
+        return String.format("SELECT %s FROM %s WHERE %s", mkString(cols, ","), fullTblName,
params);
     }
 
     /** {@inheritDoc} */
-    @Override public String insertQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String insertQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> valCols) {
         Collection<String> cols = F.concat(false, keyCols, valCols);
 
-        return String.format("INSERT INTO %s.%s(%s) VALUES(%s)", schema, tblName, mkString(cols,
","),
+        return String.format("INSERT INTO %s(%s) VALUES(%s)", fullTblName, mkString(cols,
","),
             repeat("?", cols.size(), "", ",", ""));
     }
 
     /** {@inheritDoc} */
-    @Override public String updateQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String updateQuery(String fullTblName, Collection<String> keyCols,
         Iterable<String> valCols) {
         String params = mkString(valCols, new C1<String, String>() {
             @Override public String apply(String s) {
@@ -233,7 +233,7 @@ public class BasicJdbcDialect implements JdbcDialect {
             }
         }, "", ",", "");
 
-        return String.format("UPDATE %s.%s SET %s WHERE %s", schema, tblName, params, where(keyCols,
1));
+        return String.format("UPDATE %s SET %s WHERE %s", fullTblName, params, where(keyCols,
1));
     }
 
     /** {@inheritDoc} */
@@ -242,20 +242,20 @@ public class BasicJdbcDialect implements JdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String mergeQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String mergeQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> uniqCols) {
         return "";
     }
 
     /** {@inheritDoc} */
-    @Override public String removeQuery(String schema, String tblName, Iterable<String>
keyCols) {
+    @Override public String removeQuery(String fullTblName, Iterable<String> keyCols)
{
         String whereParams = mkString(keyCols, new C1<String, String>() {
             @Override public String apply(String s) {
                 return s + "=?";
             }
         }, "", " AND ", "");
 
-        return String.format("DELETE FROM %s.%s WHERE %s", schema, tblName, whereParams);
+        return String.format("DELETE FROM %s WHERE %s", fullTblName, whereParams);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/DB2Dialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/DB2Dialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/DB2Dialect.java
index fecc2ae..bc55d97 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/DB2Dialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/DB2Dialect.java
@@ -31,7 +31,7 @@ public class DB2Dialect extends BasicJdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String mergeQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String mergeQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> uniqCols) {
 
         Collection<String> cols = F.concat(false, keyCols, uniqCols);
@@ -56,13 +56,13 @@ public class DB2Dialect extends BasicJdbcDialect {
             }
         }, "", ", ", "");
 
-        return String.format("MERGE INTO %s.%s t" +
+        return String.format("MERGE INTO %s t" +
                 " USING (VALUES(%s)) AS v (%s)" +
                 "  ON %s" +
                 " WHEN MATCHED THEN" +
                 "  UPDATE SET %s" +
                 " WHEN NOT MATCHED THEN" +
-                "  INSERT (%s) VALUES (%s)", schema, tblName, repeat("?", cols.size(), "",
",", ""), colsLst,
+                "  INSERT (%s) VALUES (%s)", fullTblName, repeat("?", cols.size(), "", ",",
""), colsLst,
             match, setCols, colsLst, valuesCols);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/H2Dialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/H2Dialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/H2Dialect.java
index 13cabe0..a97e144 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/H2Dialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/H2Dialect.java
@@ -31,11 +31,11 @@ public class H2Dialect extends BasicJdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String mergeQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String mergeQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> uniqCols) {
         Collection<String> cols = F.concat(false, keyCols, uniqCols);
 
-        return String.format("MERGE INTO %s (%s) KEY (%s) VALUES(%s)", tblName, mkString(cols,
","),
+        return String.format("MERGE INTO %s (%s) KEY (%s) VALUES(%s)", fullTblName, mkString(cols,
","),
             mkString(keyCols, ","), repeat("?", cols.size(), "", ", ", ""));
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/JdbcDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/JdbcDialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/JdbcDialect.java
index ad61d14..ab652ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/JdbcDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/JdbcDialect.java
@@ -26,69 +26,63 @@ public interface JdbcDialect {
     /**
      * Construct select count query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns for order.
      * @return Query for select count.
      */
-    public String loadCacheSelectRangeQuery(String schema, String tblName, Collection<String>
keyCols);
+    public String loadCacheSelectRangeQuery(String fullTblName, Collection<String>
keyCols);
 
     /**
      * Construct select count query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns for order.
      * @param uniqCols Database unique value columns.
      * @param appendLowerBound Need add lower bound for range.
      * @param appendUpperBound Need add upper bound for range.
      * @return Query for select count.
      */
-    public String loadCacheRangeQuery(String schema, String tblName,
+    public String loadCacheRangeQuery(String fullTblName,
         Collection<String> keyCols, Iterable<String> uniqCols, boolean appendLowerBound,
boolean appendUpperBound);
 
     /**
      * Construct load cache query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param uniqCols Database unique value columns.
      * @return Load cache query.
      */
-    public String loadCacheQuery(String schema, String tblName, Iterable<String> uniqCols);
+    public String loadCacheQuery(String fullTblName, Iterable<String> uniqCols);
 
     /**
      * Construct load query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns.
      * @param cols Selected columns.
      * @param keyCnt Key count.
      * @return Load query.
      */
-    public String loadQuery(String schema, String tblName, Collection<String> keyCols,
Iterable<String> cols,
+    public String loadQuery(String fullTblName, Collection<String> keyCols, Iterable<String>
cols,
         int keyCnt);
 
     /**
      * Construct insert query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns.
      * @param valCols Database value columns.
      */
-    public String insertQuery(String schema, String tblName, Collection<String> keyCols,
Collection<String> valCols);
+    public String insertQuery(String fullTblName, Collection<String> keyCols, Collection<String>
valCols);
 
     /**
      * Construct update query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns.
      * @param valCols Database value columns.
      */
-    public String updateQuery(String schema, String tblName, Collection<String> keyCols,
Iterable<String> valCols);
+    public String updateQuery(String fullTblName, Collection<String> keyCols, Iterable<String>
valCols);
 
     /**
      * @return {@code True} if database support merge operation.
@@ -98,23 +92,21 @@ public interface JdbcDialect {
     /**
      * Construct merge query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns.
      * @param uniqCols Database unique value columns.
      * @return Put query.
      */
-    public String mergeQuery(String schema, String tblName, Collection<String> keyCols,
Collection<String> uniqCols);
+    public String mergeQuery(String fullTblName, Collection<String> keyCols, Collection<String>
uniqCols);
 
     /**
      * Construct remove query.
      *
-     * @param schema Database schema name.
-     * @param tblName Database table name.
+     * @param fullTblName Full table name.
      * @param keyCols Database key columns.
      * @return Remove query.
      */
-    public String removeQuery(String schema, String tblName, Iterable<String> keyCols);
+    public String removeQuery(String fullTblName, Iterable<String> keyCols);
 
     /**
      * Get max query parameters count.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/MySQLDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/MySQLDialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/MySQLDialect.java
index f2a1565..df16841 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/MySQLDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/MySQLDialect.java
@@ -31,7 +31,7 @@ public class MySQLDialect extends BasicJdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String mergeQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String mergeQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> uniqCols) {
 
         Collection<String> cols = F.concat(false, keyCols, uniqCols);
@@ -42,7 +42,7 @@ public class MySQLDialect extends BasicJdbcDialect {
             }
         }, "", ", ", "");
 
-        return String.format("INSERT INTO %s.%s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE
%s", schema, tblName,
+        return String.format("INSERT INTO %s (%s) VALUES (%s) ON DUPLICATE KEY UPDATE %s",
fullTblName,
             mkString(cols, ", "), repeat("?", cols.size(), "", ",", ""), updPart);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/OracleDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/OracleDialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/OracleDialect.java
index e85e890..351f10a 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/OracleDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/OracleDialect.java
@@ -31,7 +31,7 @@ public class OracleDialect extends BasicJdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String mergeQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String mergeQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> uniqCols) {
         Collection<String> cols = F.concat(false, keyCols, uniqCols);
 
@@ -61,12 +61,12 @@ public class OracleDialect extends BasicJdbcDialect {
             }
         }, "", ", ", "");
 
-        return String.format("MERGE INTO %s.%s t" +
+        return String.format("MERGE INTO %s t" +
             " USING (SELECT %s FROM dual) v" +
             "  ON %s" +
             " WHEN MATCHED THEN" +
             "  UPDATE SET %s" +
             " WHEN NOT MATCHED THEN" +
-            "  INSERT (%s) VALUES (%s)", schema, tblName, selCols, match, setCols, colsLst,
valuesCols);
+            "  INSERT (%s) VALUES (%s)", fullTblName, selCols, match, setCols, colsLst, valuesCols);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ffd877d3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
index df8cef9..2de61b2 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
@@ -31,7 +31,7 @@ public class SQLServerDialect extends BasicJdbcDialect {
     }
 
     /** {@inheritDoc} */
-    @Override public String mergeQuery(String schema, String tblName, Collection<String>
keyCols,
+    @Override public String mergeQuery(String fullTblName, Collection<String> keyCols,
         Collection<String> uniqCols) {
         Collection<String> cols = F.concat(false, keyCols, uniqCols);
 
@@ -55,13 +55,13 @@ public class SQLServerDialect extends BasicJdbcDialect {
             }
         }, "", ", ", "");
 
-        return String.format("MERGE INTO %s.%s t" +
+        return String.format("MERGE INTO %s t" +
                 " USING (VALUES(%s)) AS v (%s)" +
                 "  ON %s" +
                 " WHEN MATCHED THEN" +
                 "  UPDATE SET %s" +
                 " WHEN NOT MATCHED THEN" +
-                "  INSERT (%s) VALUES (%s);", schema, tblName, repeat("?", cols.size(), "",
",", ""), colsLst,
+                "  INSERT (%s) VALUES (%s);", fullTblName, repeat("?", cols.size(), "", ",",
""), colsLst,
             match, setCols, colsLst, valuesCols);
     }
 }


Mime
View raw message