[jbosscache-commits] JBoss Cache SVN: r7386 - in core/trunk/src: main/java/org/jboss/cache/loader and 5 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Jan 7 12:42:40 EST 2009


Author: manik.surtani at jboss.com
Date: 2009-01-07 12:42:40 -0500 (Wed, 07 Jan 2009)
New Revision: 7386

Modified:
   core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
   core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
   core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
   core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
   core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
   core/trunk/src/main/resources/cache-jdbc.properties
   core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
   core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
   core/trunk/src/test/resources/cache-jdbc.properties
   core/trunk/src/test/resources/configs/conf2x/cacheloader-enabled-cache.xml
Log:
JBCACHE-1460 -  Inefficient remove() in JDBCCacheLoader
as well as other JDBC Cache Loader improvements, including logging and pretty printing.

Modified: core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml	2009-01-07 17:42:40 UTC (rev 7386)
@@ -164,7 +164,6 @@
             cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
             cache.jdbc.user=root
             cache.jdbc.password=
-            cache.jdbc.sql-concat=concat(1,2)
          </properties>
       </loader>
   </loaders>
@@ -806,7 +805,6 @@
             cache.jdbc.url=jdbc:oracle:thin:@localhost:1521:JBOSSDB
             cache.jdbc.user=SCOTT
             cache.jdbc.password=TIGER
-            cache.jdbc.sql-concat=concat(1,2)
           </properties>
       </loader>
   </loaders>
@@ -855,7 +853,6 @@
             cache.jdbc.url=jdbc:oracle:thin:@localhost:1521:JBOSSDB
             cache.jdbc.user=SCOTT
             cache.jdbc.password=TIGER
-            cache.jdbc.sql-concat=concat(1,2)
             cache.jdbc.connection.factory=org.jboss.cache.loader.C3p0ConnectionFactory
             c3p0.maxPoolSize=20
             c3p0.checkoutTimeout=5000

Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -27,9 +27,9 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.Modification;
+import org.jboss.cache.Modification.ModificationType;
 import org.jboss.cache.Region;
 import org.jboss.cache.RegionManager;
-import org.jboss.cache.Modification.ModificationType;
 import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.marshall.Marshaller;
@@ -209,7 +209,9 @@
       if (r != null)
       {
          if (trace)
+         {
             log.trace("Using region " + r.getFqn() + ", which has registered class loader " + r.getClassLoader() + " as a context class loader.");
+         }
          // set the region's class loader as the thread's context classloader
          needToResetLoader = true;
          current = Thread.currentThread();

Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -74,6 +74,50 @@
    // serialized, upon deserialization it cannot be added to.
    private static final Map<Object, Object> EMPTY_HASHMAP = new HashMap<Object, Object>(0, 1);
 
+   /**
+    * Creates a prepared statement using the given connection and SQL string, logs the statement that is about to be
+    * executed to the logger, and optionally sets String parameters provided on the prepared statement before
+    * returning the prepared statement.
+    *
+    * @param conn   Connection to use to create the prepared statement
+    * @param sql    SQL to use with the prepared statement
+    * @param params optional parameters to add to the statement.
+    * @return a prepared statement
+    * @throws Exception if there are problems
+    */
+   protected PreparedStatement prepareAndLogStatement(Connection conn, String sql, String... params) throws Exception
+   {
+      PreparedStatement ps = conn.prepareStatement(sql);
+      for (int i = 0; i < params.length; i++) ps.setString(i + 1, params[i]);
+
+      // Logging the SQL we plan to run
+      if (getLogger().isTraceEnabled())
+      {
+         StringBuilder sb = new StringBuilder("Executing SQL statement [");
+         sb.append(sql).append("]");
+         if (params.length != 0)
+         {
+            sb.append(" with params ");
+            boolean first = true;
+            for (String param : params)
+            {
+               if (first)
+               {
+                  first = false;
+               }
+               else
+               {
+                  sb.append(", ");
+               }
+               sb.append("[").append(param).append("]");
+            }
+         }
+
+         getLogger().trace(sb.toString());
+      }
+      return ps;
+   }
+
    public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
    {
       config = processConfig(base);
@@ -86,7 +130,9 @@
        defined or the default one */
             getLogger().debug("Initialising with a connection factory since data source is not provided.");
             if (getLogger().isDebugEnabled())
+            {
                getLogger().debug("Using connection factory " + config.getConnectionFactoryClass());
+            }
             cf = (ConnectionFactory) Util.loadClass(config.getConnectionFactoryClass()).newInstance();
          }
          catch (Exception e)
@@ -142,14 +188,8 @@
       ResultSet rs = null;
       try
       {
-         if (getLogger().isDebugEnabled())
-         {
-            getLogger().debug("executing sql: " + config.getSelectChildNamesSql() + " (" + fqn + ")");
-         }
-
          con = cf.getConnection();
-         ps = con.prepareStatement(config.getSelectChildNamesSql());
-         ps.setString(1, fqn.toString());
+         ps = prepareAndLogStatement(con, config.getSelectChildNamesSql(), fqn.toString());
          lock.acquireLock(fqn, false);
          rs = ps.executeQuery();
          if (rs.next())
@@ -276,7 +316,7 @@
       try
       {
          conn = cf.getConnection();
-         ps = conn.prepareStatement(config.getDummyTableRemovalDDL());
+         ps = prepareAndLogStatement(conn, config.getDummyTableRemovalDDL());
          ps.execute();
       }
       catch (Exception e)
@@ -292,10 +332,10 @@
       try
       {
          conn = cf.getConnection();
-         ps = conn.prepareStatement(config.getDummyTableCreationDDL());
+         ps = prepareAndLogStatement(conn, config.getDummyTableCreationDDL());
          ps.execute();
          safeClose(ps);
-         ps = conn.prepareStatement(config.getDummyTablePopulationSql());
+         ps = prepareAndLogStatement(conn, config.getDummyTablePopulationSql());
          ps.execute();
       }
       finally
@@ -359,8 +399,7 @@
       try
       {
          conn = cf.getConnection();
-         ps = conn.prepareStatement(config.getExistsSql());
-         ps.setString(1, name.toString());
+         ps = prepareAndLogStatement(conn, config.getExistsSql(), name.toString());
          rs = ps.executeQuery();
          return rs.next();
       }
@@ -426,16 +465,8 @@
       ResultSet rs = null;
       try
       {
-         if (getLogger().isDebugEnabled())
-         {
-            getLogger().debug("executing sql: " + config.getSelectNodeSql() + " (" + name + ")");
-         }
-
          con = cf.getConnection();
-
-         ps = con.prepareStatement(config.getSelectNodeSql());
-         ps.setString(1, name.toString());
-
+         ps = prepareAndLogStatement(con, config.getSelectNodeSql(), name.toString());
          rs = ps.executeQuery();
 
          if (rs.next())
@@ -488,13 +519,8 @@
       PreparedStatement ps = null;
       try
       {
-         if (getLogger().isDebugEnabled())
-         {
-            getLogger().debug("executing sql: " + config.getInsertNodeSql() + " (" + name + ")");
-         }
-
          con = cf.getConnection();
-         ps = con.prepareStatement(config.getInsertNodeSql());
+         ps = prepareAndLogStatement(con, config.getInsertNodeSql());
 
          populatePreparedStatementForInsert(name, dataMap, ps);
 
@@ -576,13 +602,8 @@
       PreparedStatement ps = null;
       try
       {
-         if (getLogger().isDebugEnabled())
-         {
-            getLogger().debug("executing sql: " + config.getUpdateNodeSql());
-         }
-
          con = cf.getConnection();
-         ps = con.prepareStatement(config.getUpdateNodeSql());
+         ps = prepareAndLogStatement(con, config.getUpdateNodeSql());
 
          if (node == null) node = EMPTY_HASHMAP;
 

Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -43,36 +43,36 @@
    private static final boolean CREATE_TABLE_DEFAULT = true;
    private static final boolean DROP_TABLE_DEFAULT = false;
    private static final String PARENT_COLUMN_DEFAULT = "parent";
-   private static final String NODE_TYPE_DEFAULT = "blob";
+   private static final String NODE_TYPE_DEFAULT = "BLOB";
    private static final String NODE_COLUMN_DEFAULT = "node";
-   private static final String FQN_TYPE_DEFAULT = "varchar(255)";
+   private static final String FQN_TYPE_DEFAULT = "VARCHAR(255)";
    private static final String FQN_COLUMN_DEFAULT = "fqn";
    private static final String PRIMARY_KEY_DEFAULT = "jbosscache_pk";
    private static final String TABLE_DEFAULT = "jbosscache";
 
-   private boolean createTable = CREATE_TABLE_DEFAULT;
-   private String createTableDDL;
-   private String datasourceName;
-   private String deleteAllSql;
-   private String deleteNodeSql;
-   private boolean dropTable = DROP_TABLE_DEFAULT;
-   private String dropTableDDL;
-   private String driverClass;
-   private String insertNodeSql;
-   private String jdbcURL;
-   private String jdbcUser;
-   private String jdbcPassword;
-   private String selectChildFqnsSql;
-   private String selectChildNamesSql;
-   private String selectNodeSql;
-   private String updateNodeSql;
-   private String updateTableSql;
-   private String existsSql;
-   private String connectionFactoryClass;
-   private String primaryKey = PRIMARY_KEY_DEFAULT;
-   private String fqnType = FQN_TYPE_DEFAULT;
-   private String nodeType = NODE_TYPE_DEFAULT;
-   private String parentColumn = PARENT_COLUMN_DEFAULT;
+   protected boolean createTable = CREATE_TABLE_DEFAULT;
+   protected String createTableDDL;
+   protected String datasourceName;
+   protected String deleteAllSql;
+   protected String deleteNodeSql;
+   protected boolean dropTable = DROP_TABLE_DEFAULT;
+   protected String dropTableDDL;
+   protected String driverClass;
+   protected String insertNodeSql;
+   protected String jdbcURL;
+   protected String jdbcUser;
+   protected String jdbcPassword;
+   protected String selectChildFqnsSql;
+   protected String selectChildNamesSql;
+   protected String selectNodeSql;
+   protected String updateNodeSql;
+   protected String updateTableSql;
+   protected String existsSql;
+   protected String connectionFactoryClass;
+   protected String primaryKey = PRIMARY_KEY_DEFAULT;
+   protected String fqnType = FQN_TYPE_DEFAULT;
+   protected String nodeType = NODE_TYPE_DEFAULT;
+   protected String parentColumn = PARENT_COLUMN_DEFAULT;
    protected String table = TABLE_DEFAULT;
    protected String nodeColumn = NODE_COLUMN_DEFAULT;
    protected String fqnColumn = FQN_COLUMN_DEFAULT;
@@ -474,26 +474,13 @@
 
    private String constructDropTableDDL()
    {
-      return "drop table " + table;
+      return "DROP TABLE " + table;
    }
 
    private String constructCreateTableDDL()
    {
-      return "create table " +
-            table +
-            "(" +
-            fqnColumn +
-            " " +
-            fqnType +
-            " not null, " +
-            nodeColumn +
-            " " +
-            nodeType +
-            ", " +
-            parentColumn +
-            " " +
-            fqnType +
-            ", constraint " + primaryKey + " primary key (" + fqnColumn + "))";
+      return "CREATE TABLE " + table + "(" + fqnColumn + " " + fqnType + " NOT NULL, " + nodeColumn + " " + nodeType +
+            ", " + parentColumn + " " + fqnType + ", CONSTRAINT " + primaryKey + " PRIMARY KEY (" + fqnColumn + "))";
    }
 
    @Override
@@ -570,32 +557,32 @@
 
    private String constructSelectNodeSql()
    {
-      return "select " + nodeColumn + " from " + table + " where " + fqnColumn + "=?";
+      return "SELECT " + nodeColumn + " FROM " + table + " WHERE " + fqnColumn + " = ?";
    }
 
    private String constructUpdateNodeSql()
    {
-      return "update " + table + " set " + nodeColumn + "=? where " + fqnColumn + "=?";
+      return "UPDATE " + table + " SET " + nodeColumn + " = ? WHERE " + fqnColumn + " = ?";
    }
 
    private String constructDeleteAllSql()
    {
-      return "delete from " + table;
+      return "DELETE FROM " + table;
    }
 
    private String constructDeleteNodeSql()
    {
-      return "delete from " + table + " where " + fqnColumn + "=?";
+      return "DELETE FROM " + table + " WHERE " + fqnColumn + " = ?";
    }
 
    private String constructSelectChildNamesSql()
    {
-      return "select " + fqnColumn + " from " + table + " where " + parentColumn + "=?";
+      return "SELECT " + fqnColumn + " FROM " + table + " WHERE " + parentColumn + " = ?";
    }
 
    private String constructExistsSql()
    {
-      return "select '1' from " + table + " where " + fqnColumn + "=?";
+      return "SELECT '1' FROM " + table + " WHERE " + fqnColumn + " = ?";
    }
 
    private String constructInsertNodeSql()
@@ -628,16 +615,16 @@
 
    public String getDummyTableCreationDDL()
    {
-      return "create table " + table + "_D (i CHAR)";
+      return "CREATE TABLE " + table + "_D (i CHAR)";
    }
 
    public String getDummyTableRemovalDDL()
    {
-      return "drop table " + table + "_D";
+      return "DROP TABLE " + table + "_D";
    }
 
    public String getDummyTablePopulationSql()
    {
-      return "insert into " + table + "_D values ('x')";
+      return "INSERT INTO " + table + "_D VALUES ('x')";
    }
 }
\ No newline at end of file

Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -50,8 +50,6 @@
  * <p/>
  * Additional configuration info: <br>
  * <ul>
- * <li>cache.jdbc.sql-concat : DBMS specific function for concat strings. Most likely this will be concat(1,2), but might
- * be different for proprietary systems.</li>
  * <li>
  * cache.jdbc.batch.enable: whether or not to use batching on repetitive operations (e.g. inserts during state transfer).
  * Enabling batching should give an important performance boost. It might be required to disable this if the JDBC driver
@@ -170,7 +168,7 @@
          con = cf.getConnection();
          autocommitPrev = con.getAutoCommit();
          if (config.isBatchEnabled()) con.setAutoCommit(false);
-         ps = con.prepareStatement(config.getInsertNodeSql());
+         ps = prepareAndLogStatement(con, config.getInsertNodeSql());
          for (Object aNodeData : nodeData)
          {
             NodeData nd = (NodeData) aNodeData;
@@ -245,15 +243,13 @@
       try
       {
          conn = cf.getConnection();
-         ps = conn.prepareStatement(config.getDeleteNodeSql());
+
+         String fqnString = fqn.toString();
          //apend / at the end avoids this issue: 'a/b/cd' is not a child of 'a/b/c'
-         ps.setString(1, fqn.isRoot() ? fqn.toString() : fqn + Fqn.SEPARATOR);
+         String fqnWildcardString = getFqnWildcardString(fqnString, fqn);
+         ps = prepareAndLogStatement(conn, config.getDeleteNodeSql(), fqnString, fqnWildcardString);
          lock.acquireLock(fqn, true);
          ps.executeUpdate();
-         if (getLogger().isTraceEnabled())
-         {
-            getLogger().trace("Deleting all the children of " + fqn + ". Used sql is'" + config.getDeleteNodeSql() + '\'');
-         }
       }
       catch (SQLException e)
       {
@@ -287,9 +283,11 @@
       try
       {
          connection = cf.getConnection();
-         ps = connection.prepareStatement(config.getRecursiveChildrenSql());
-         ps.setString(1, fqn.isRoot() ? fqn.toString() : fqn.toString() + Fqn.SEPARATOR);
+         String fqnString = fqn.toString();
+         String fqnWildcardString = getFqnWildcardString(fqnString, fqn);
+         ps = prepareAndLogStatement(connection, config.getRecursiveChildrenSql(), fqnString, fqnWildcardString);
          rs = ps.executeQuery();
+
          while (rs.next())
          {
             Map<Object, Object> attributes = readAttributes(rs, 2);
@@ -311,6 +309,11 @@
       }
    }
 
+   private String getFqnWildcardString(String fqnString, Fqn fqn)
+   {
+      return fqnString + (fqn.isRoot() ? "" : Fqn.SEPARATOR) + '%';
+   }
+
    private Map<Object, Object> readAttributes(ResultSet rs, int index) throws SQLException
    {
       Map<Object, Object> result;
@@ -354,14 +357,12 @@
       while (!exists(currentNode));
    }
 
-
    @Override
    protected Log getLogger()
    {
       return log;
    }
 
-
    /**
     * Start is overwritten for the sake of backward compatibility only.
     * Here is the issue: old implementation does not create a Fqn.ROOT if not specifically told so.
@@ -390,13 +391,8 @@
       ResultSet rs = null;
       try
       {
-         if (getLogger().isDebugEnabled())
-         {
-            getLogger().debug("executing sql: " + config.getNodeCountSql());
-         }
-
          conn = cf.getConnection();
-         ps = conn.prepareStatement(config.getNodeCountSql());
+         ps = prepareAndLogStatement(conn, config.getNodeCountSql());
          rs = ps.executeQuery();
          rs.next();//count(*) will always return one row
          return rs.getInt(1);

Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -21,8 +21,6 @@
  */
 package org.jboss.cache.loader;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 
 import java.util.Properties;
@@ -36,19 +34,11 @@
  */
 public class JDBCCacheLoaderConfig extends AdjListJDBCCacheLoaderConfig
 {
-
    private static final long serialVersionUID = -8371846151643130271L;
 
-   private static final Log log = LogFactory.getLog(JDBCCacheLoaderConfig.class);
-
-   private String deleteNodeSql;
    private String recursiveChildrenSql;
    private String nodeCountSql;
-   private String sqlConcat;
 
-   private String startingWith;
-   private String appendSeparator;
-
    private boolean batchEnabled = true;//by default enable batching during state transfer
 
    private long batchSize = 1000; //default state transfer batch size
@@ -68,10 +58,6 @@
    public void setProperties(Properties props)
    {
       super.setProperties(props);
-      sqlConcat = props.getProperty("cache.jdbc.sql-concat");
-
-      disectSqlConcat();
-
       deleteNodeSql = constructDeleteNodeSql();
       recursiveChildrenSql = constructRecursiveChildrenSql();
       nodeCountSql = constructNodeCountSql();
@@ -89,11 +75,7 @@
    @Override
    public String getDeleteNodeSql()
    {
-      if (startingWith == null || appendSeparator == null || deleteNodeSql == null)
-      {
-         disectSqlConcat();
-         setDeleteNodeSql(constructDeleteNodeSql());
-      }
+      if (deleteNodeSql == null) deleteNodeSql = constructDeleteNodeSql();
 
       return deleteNodeSql;
    }
@@ -103,11 +85,7 @@
     */
    public String getRecursiveChildrenSql()
    {
-      if (startingWith == null || appendSeparator == null || recursiveChildrenSql == null)
-      {
-         disectSqlConcat();
-         setRecursiveChildrenSql(constructRecursiveChildrenSql());
-      }
+      if (recursiveChildrenSql == null) recursiveChildrenSql = constructRecursiveChildrenSql();
 
       return recursiveChildrenSql;
    }
@@ -122,11 +100,7 @@
     */
    public String getNodeCountSql()
    {
-      if (startingWith == null || appendSeparator == null || nodeCountSql == null)
-      {
-         disectSqlConcat();
-         setNodeCountSql(constructNodeCountSql());
-      }
+      if (nodeCountSql == null) nodeCountSql = constructNodeCountSql();
 
       return nodeCountSql;
    }
@@ -136,37 +110,17 @@
       this.nodeCountSql = nodeCountSql;
    }
 
+   @Deprecated
    public String getSqlConcat()
    {
-      return sqlConcat;
+      return "";
    }
 
+   @Deprecated
    public void setSqlConcat(String sqlConcat)
    {
-      testImmutability("sqlConcat");
-      this.sqlConcat = sqlConcat;
    }
 
-   public String getStartingWith()
-   {
-      return startingWith;
-   }
-
-   public void setStartingWith(String startingWith)
-   {
-      this.startingWith = startingWith;
-   }
-
-   public String getAppendSeparator()
-   {
-      return appendSeparator;
-   }
-
-   public void setAppendSeparator(String appendSeparator)
-   {
-      this.appendSeparator = appendSeparator;
-   }
-
    /**
     * If batch is enabled certain operations (e.g. state transfer) will use {@link java.sql.PreparedStatement#addBatch(String)}
     * approach for insertig data into the database. This normally brings significant performance improvements.
@@ -188,29 +142,18 @@
       return batchSize;
    }
 
-   private void disectSqlConcat()
-   {
-      if (sqlConcat == null)
-      {
-         log.info("Missing JDBCCacheLoader config 'cache.jdbc.sql-concat', using default value:'concat(1,2)'");
-         sqlConcat = "concat(1,2)";
-      }
-      startingWith = sqlConcat.replace('1', '?').replace("2", "'%'"); //concat(?, '%')
-      appendSeparator = sqlConcat.replace("1", fqnColumn).replace("2", "'/'"); //concat(fqnColumn, '/')
-   }
-
    private String constructNodeCountSql()
    {
-      return "select count(*) from " + table;
+      return "SELECT COUNT(*) FROM " + table;
    }
 
    private String constructRecursiveChildrenSql()
    {
-      return "select " + fqnColumn + "," + nodeColumn + " from " + table + " where " + appendSeparator + " like " + startingWith;
+      return "SELECT " + fqnColumn + "," + nodeColumn + " FROM " + table + " WHERE " + fqnColumn + " = ? OR " + fqnColumn + " LIKE ?";
    }
 
    private String constructDeleteNodeSql()
    {
-      return "delete from " + table + " where " + appendSeparator + " like " + startingWith;
+      return "DELETE FROM " + table + " WHERE " + fqnColumn + " = ? OR " + fqnColumn + " LIKE ?";
    }
 }
\ No newline at end of file

Modified: core/trunk/src/main/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/main/resources/cache-jdbc.properties	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/main/resources/cache-jdbc.properties	2009-01-07 17:42:40 UTC (rev 7386)
@@ -1,9 +1,9 @@
-##
-# Standard JBC table properties
+# Standard JBoss Cache table properties
+
 # The table name can also be prepended with schema name for the given table.
 # Even though there is an Sql92 standard syntax for this: <schema_name>.<table name>
-#schema has different meanings accross various DBMS: Oracle - user name; PointBase - database name
-# Microsoft SQL Server & DB2 - schema name corresponds to the catalog owner 
+# schema has different meanings accross various DBMS: Oracle - user name; PointBase - database name
+# Microsoft SQL Server & DB2 - schema name corresponds to the catalog owner
 cache.jdbc.table.name=jbosscache
 cache.jdbc.table.create=true
 cache.jdbc.table.drop=false
@@ -13,12 +13,6 @@
 cache.jdbc.node.column=node
 cache.jdbc.node.type=BINARY
 cache.jdbc.parent.column=parent
-# Specify your DBMS's string concatenation function syntax in the following manner: concat(1 , 2) -> '12'.
-# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql, PostgreSQL.
-#
-# Derby - does not support 'concat', but '1 || 2' . If no value is sepcified then concat(1 , 2) is used by default.
-#cache.jdbc.sql-concat=1 || 2
-#cache.jdbc.sql-concat=concat(1 , 2)
 
 # JBoss Cache Table properties for Hypersonic, just overrides
 #cache.jdbc.node.type=OBJECT
@@ -30,20 +24,19 @@
 ##
 # JDBC driver specific properties
 
-# Hypersonic
-#cache.jdbc.node.type=OBJECT
-
 ## MySql
 #cache.jdbc.driver=com.mysql.jdbc.Driver
 #cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
 #cache.jdbc.user=root
 #cache.jdbc.password=admin
+#cache.jdbc.node.type=BLOB
 
 ## Oracle
 #cache.jdbc.driver=oracle.jdbc.OracleDriver
 #cache.jdbc.url=jdbc:oracle:thin:@192.168.0.100:1521:JBOSSDB
 #cache.jdbc.user=jboss
 #cache.jdbc.password=sa
+#cache.jdbc.node.type=BLOB
 
 ## MS Sql Server
 #cache.jdbc.driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
@@ -57,15 +50,17 @@
 #cache.jdbc.url=jdbc:pointbase:server://localhost:9092/jboss,new
 #cache.jdbc.user=PBPUBLIC
 #cache.jdbc.password=PBPUBLIC
+#cache.jdbc.node.type=BLOB
 
 ## PostgreSQL
 #cache.jdbc.driver = org.postgresql.Driver
 #cache.jdbc.url=jdbc:postgresql://192.168.0.100:5432/jbossdb
 #cache.jdbc.user=postgres
 #cache.jdbc.password=admin
+#cache.jdbc.node.type=BLOB
 
-## Derby
+## HSQL
 cache.jdbc.driver = org.hsqldb.jdbcDriver
 cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
 cache.jdbc.user=sa
-cache.jdbc.password=
\ No newline at end of file
+cache.jdbc.password=

Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -73,7 +73,6 @@
       append("cache.jdbc.user", prop, p);
       append("cache.jdbc.password", prop, p);
       append("cache.jdbc.node.type", prop, p);
-      append("cache.jdbc.sql-concat", prop, p);
       append("cache.jdbc.table.name", prop, p);
       append("cache.jdbc.table.primarykey", prop, p);
       return p.toString();

Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java	2009-01-07 17:42:40 UTC (rev 7386)
@@ -232,8 +232,7 @@
                   + prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
                   + prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
                   + prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
-                  + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.sql-concat="
-                  + prop.getProperty("cache.jdbc.sql-concat") + "\n" + "cache.jdbc.table.name="
+                  + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.table.name="
                   + prop.getProperty("cache.jdbc.table.name");
 
             CacheLoaderConfig clc = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.JDBCCacheLoader",

Modified: core/trunk/src/test/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/test/resources/cache-jdbc.properties	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/test/resources/cache-jdbc.properties	2009-01-07 17:42:40 UTC (rev 7386)
@@ -1,8 +1,8 @@
-##
-# Standard JBC table properties
+# Standard JBoss Cache table properties
+
 # The table name can also be prepended with schema name for the given table.
 # Even though there is an Sql92 standard syntax for this: <schema_name>.<table name>
-#schema has different meanings accross various DBMS: Oracle - user name; PointBase - database name
+# schema has different meanings accross various DBMS: Oracle - user name; PointBase - database name
 # Microsoft SQL Server & DB2 - schema name corresponds to the catalog owner 
 cache.jdbc.table.name=jbosscache
 cache.jdbc.table.create=true
@@ -13,10 +13,6 @@
 cache.jdbc.node.column=node
 cache.jdbc.node.type=BINARY
 cache.jdbc.parent.column=parent
-# Specify your DBMS's string concatenation function syntax in the following manner: concat(1 , 2) -> '12'.
-# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql, PostgreSQL. Derby - on which 
-#the tests are run does not support 'concat', but '1 || 2' . If no value is sepcified then concat(1 , 2) is used by default.
-cache.jdbc.sql-concat=1 || 2
 
 # JBoss Cache Table properties for Hypersonic, just overrides
 #cache.jdbc.node.type=OBJECT
@@ -28,20 +24,19 @@
 ##
 # JDBC driver specific properties
 
-# Hypersonic
-#cache.jdbc.node.type=OBJECT
-
 ## MySql
 #cache.jdbc.driver=com.mysql.jdbc.Driver
 #cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
 #cache.jdbc.user=root
 #cache.jdbc.password=admin
+#cache.jdbc.node.type=BLOB
 
 ## Oracle
 #cache.jdbc.driver=oracle.jdbc.OracleDriver
 #cache.jdbc.url=jdbc:oracle:thin:@192.168.0.100:1521:JBOSSDB
 #cache.jdbc.user=jboss
 #cache.jdbc.password=sa
+#cache.jdbc.node.type=BLOB
 
 ## MS Sql Server
 #cache.jdbc.driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
@@ -55,12 +50,14 @@
 #cache.jdbc.url=jdbc:pointbase:server://localhost:9092/jboss,new
 #cache.jdbc.user=PBPUBLIC
 #cache.jdbc.password=PBPUBLIC
+#cache.jdbc.node.type=BLOB
 
 ## PostgreSQL
 #cache.jdbc.driver = org.postgresql.Driver
 #cache.jdbc.url=jdbc:postgresql://192.168.0.100:5432/jbossdb
 #cache.jdbc.user=postgres
 #cache.jdbc.password=admin
+#cache.jdbc.node.type=BLOB
 
 ## HSQL
 cache.jdbc.driver = org.hsqldb.jdbcDriver

Modified: core/trunk/src/test/resources/configs/conf2x/cacheloader-enabled-cache.xml
===================================================================
--- core/trunk/src/test/resources/configs/conf2x/cacheloader-enabled-cache.xml	2009-01-07 17:42:29 UTC (rev 7385)
+++ core/trunk/src/test/resources/configs/conf2x/cacheloader-enabled-cache.xml	2009-01-07 17:42:40 UTC (rev 7386)
@@ -8,111 +8,110 @@
 
 <server>
 
-   <!-- ==================================================================== -->
-   <!-- Defines TreeCache configuration                                      -->
-   <!-- ==================================================================== -->
+    <!-- ==================================================================== -->
+    <!-- Defines TreeCache configuration                                      -->
+    <!-- ==================================================================== -->
 
-   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
-          name="jboss.cache:service=TreeCache">
+    <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+           name="jboss.cache:service=TreeCache">
 
-      <depends>jboss:service=Naming</depends>
-      <depends>jboss:service=TransactionManager</depends>
+        <depends>jboss:service=Naming</depends>
+        <depends>jboss:service=TransactionManager</depends>
 
-      <!--
-          Configure the TransactionManager
-      -->
-      <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
-      </attribute>
+        <!--
+            Configure the TransactionManager
+        -->
+        <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+        </attribute>
 
 
-      <!--
-          Node locking level : SERIALIZABLE
-                               REPEATABLE_READ (default)
-                               READ_COMMITTED
-                               READ_UNCOMMITTED
-                               NONE
-      -->
-      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+        <!--
+            Node locking level : SERIALIZABLE
+                                 REPEATABLE_READ (default)
+                                 READ_COMMITTED
+                                 READ_UNCOMMITTED
+                                 NONE
+        -->
+        <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
 
-      <!--
-           Valid modes are LOCAL
-                           REPL_ASYNC
-                           REPL_SYNC
-      -->
-      <attribute name="CacheMode">LOCAL</attribute>
+        <!--
+             Valid modes are LOCAL
+                             REPL_ASYNC
+                             REPL_SYNC
+        -->
+        <attribute name="CacheMode">LOCAL</attribute>
 
-      <!-- Max number of milliseconds to wait for a lock acquisition -->
-      <attribute name="LockAcquisitionTimeout">15000</attribute>
+        <!-- Max number of milliseconds to wait for a lock acquisition -->
+        <attribute name="LockAcquisitionTimeout">15000</attribute>
 
-      <!-- Specific eviction policy configurations. This is LRU -->
-      <attribute name="EvictionPolicyConfig">
-         <config>
-            <attribute name="wakeUpIntervalSeconds">5</attribute>
-            <!-- This defaults to 200000 if not specified -->
-            <attribute name="eventQueueSize">200000</attribute>
-            <!-- Name of the DEFAULT eviction policy class. -->
-            <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+        <!-- Specific eviction policy configurations. This is LRU -->
+        <attribute name="EvictionPolicyConfig">
+            <config>
+                <attribute name="wakeUpIntervalSeconds">5</attribute>
+                <!-- This defaults to 200000 if not specified -->
+                <attribute name="eventQueueSize">200000</attribute>
+                <!-- Name of the DEFAULT eviction policy class. -->
+                <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
 
 
-            <!-- Cache wide default -->
-            <region name="/_default_">
-               <attribute name="maxNodes">5000</attribute>
-               <attribute name="timeToLiveSeconds">3</attribute>
-            </region>
-            <region name="/org/jboss/test/data">
-               <attribute name="maxNodes">100</attribute>
-               <attribute name="timeToLiveSeconds">3</attribute>
-            </region>
-         </config>
-      </attribute>
+                <!-- Cache wide default -->
+                <region name="/_default_">
+                    <attribute name="maxNodes">5000</attribute>
+                    <attribute name="timeToLiveSeconds">3</attribute>
+                </region>
+                <region name="/org/jboss/test/data">
+                    <attribute name="maxNodes">100</attribute>
+                    <attribute name="timeToLiveSeconds">3</attribute>
+                </region>
+            </config>
+        </attribute>
 
-      <!-- Cache Passivation for Tree Cache
+        <!-- Cache Passivation for Tree Cache
 On pasivation, The objects are written to the backend store on eviction if CacheLoaderPassivation
 is true, otheriwse the objects are persisted.
 On activation, the objects are restored in the memory cache and removed from the cache loader
 if CacheLoaderPassivation is true, otherwise the objects are only loaded from the cache loader -->
-      <attribute name="CacheLoaderConfiguration">
-         <config>
-            <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
-            <passivation>false</passivation>
-            <preload>/</preload>
-            <shared>false</shared>
+        <attribute name="CacheLoaderConfiguration">
+            <config>
+                <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+                <passivation>false</passivation>
+                <preload>/</preload>
+                <shared>false</shared>
 
-            <!-- we can now have multiple cache loaders, which get chained -->
-            <cacheloader>
-               <class>org.jboss.cache.loader.JDBCCacheLoader</class>
-               <!-- same as the old CacheLoaderConfig attribute -->
-               <properties>
-                  cache.jdbc.table.name=jbosscache
-                  cache.jdbc.table.create=true
-                  cache.jdbc.table.drop=true
-                  cache.jdbc.table.primarykey=jbosscache_pk
-                  cache.jdbc.fqn.column=fqn
-                  cache.jdbc.fqn.type=varchar(255)
-                  cache.jdbc.node.column=node
-                  cache.jdbc.node.type=blob
-                  cache.jdbc.parent.column=parent
-                  cache.jdbc.driver=com.mysql.jdbc.Driver
-                  cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
-                  cache.jdbc.user=root
-                  cache.jdbc.password=
-                  cache.jdbc.sql-concat=concat(1,2)
-               </properties>
-               <!-- whether the cache loader writes are asynchronous -->
-               <async>false</async>
-               <!-- only one cache loader in the chain may set fetchPersistentState to true.
- An exception is thrown if more than one cache loader sets this to true. -->
-               <fetchPersistentState>true</fetchPersistentState>
-               <!-- determines whether this cache loader ignores writes - defaults to false. -->
-               <ignoreModifications>false</ignoreModifications>
-               <!-- if set to true, purges the contents of this cache loader when the cache starts up.
-           Defaults to false.  -->
-               <purgeOnStartup>false</purgeOnStartup>
-            </cacheloader>
-         </config>
-      </attribute>
+                <!-- we can now have multiple cache loaders, which get chained -->
+                <cacheloader>
+                    <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+                    <!-- same as the old CacheLoaderConfig attribute -->
+                    <properties>
+                        cache.jdbc.table.name=jbosscache
+                        cache.jdbc.table.create=true
+                        cache.jdbc.table.drop=true
+                        cache.jdbc.table.primarykey=jbosscache_pk
+                        cache.jdbc.fqn.column=fqn
+                        cache.jdbc.fqn.type=varchar(255)
+                        cache.jdbc.node.column=node
+                        cache.jdbc.node.type=blob
+                        cache.jdbc.parent.column=parent
+                        cache.jdbc.driver=com.mysql.jdbc.Driver
+                        cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
+                        cache.jdbc.user=root
+                        cache.jdbc.password=
+                    </properties>
+                    <!-- whether the cache loader writes are asynchronous -->
+                    <async>false</async>
+                    <!-- only one cache loader in the chain may set fetchPersistentState to true.
+      An exception is thrown if more than one cache loader sets this to true. -->
+                    <fetchPersistentState>true</fetchPersistentState>
+                    <!-- determines whether this cache loader ignores writes - defaults to false. -->
+                    <ignoreModifications>false</ignoreModifications>
+                    <!-- if set to true, purges the contents of this cache loader when the cache starts up.
+                Defaults to false.  -->
+                    <purgeOnStartup>false</purgeOnStartup>
+                </cacheloader>
+            </config>
+        </attribute>
 
-   </mbean>
+    </mbean>
 
 
 </server>




More information about the jbosscache-commits mailing list