JBoss Cache SVN: r8480 - core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: dereed
Date: 2012-01-11 15:26:35 -0500 (Wed, 11 Jan 2012)
New Revision: 8480
Modified:
core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
Log:
[JBPAPP-7898] Backport JBCACHE-1610 to 3.2.5
Modified: core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2012-01-11 20:15:24 UTC (rev 8479)
+++ core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2012-01-11 20:26:35 UTC (rev 8480)
@@ -580,7 +580,10 @@
if (dataMap != null)
{
ByteBuffer byteBuffer = marshall(dataMap);
- ps.setBinaryStream(2, byteBuffer.getStream(), byteBuffer.getLength());
+ if ( config.getUseSetBlob() )
+ ps.setBlob(2, byteBuffer.getStream(), byteBuffer.getLength());
+ else
+ ps.setBinaryStream(2, byteBuffer.getStream(), byteBuffer.getLength());
}
else
{
@@ -632,7 +635,10 @@
if (node == null) node = EMPTY_HASHMAP;
ByteBuffer byteBuffer = marshall(node);
- ps.setBinaryStream(1, byteBuffer.getStream(), byteBuffer.getLength());
+ if ( config.getUseSetBlob() )
+ ps.setBlob(1, byteBuffer.getStream(), byteBuffer.getLength());
+ else
+ ps.setBinaryStream(1, byteBuffer.getStream(), byteBuffer.getLength());
ps.setString(2, name.toString());
Modified: core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
--- core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2012-01-11 20:15:24 UTC (rev 8479)
+++ core/support-branches/3.2.5.GA_JBCACHE-1610/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2012-01-11 20:26:35 UTC (rev 8480)
@@ -42,6 +42,7 @@
private static final boolean CREATE_TABLE_DEFAULT = true;
private static final boolean DROP_TABLE_DEFAULT = false;
+ private static final boolean USE_SET_BLOB_DEFAULT = false;
private static final String PARENT_COLUMN_DEFAULT = "parent";
private static final String NODE_TYPE_DEFAULT = "BLOB";
private static final String NODE_COLUMN_DEFAULT = "node";
@@ -65,6 +66,7 @@
protected String selectChildFqnsSql;
protected String selectChildNamesSql;
protected String selectNodeSql;
+ protected boolean useSetBlob = USE_SET_BLOB_DEFAULT; // use ps.setBlob for insert and update
protected String updateNodeSql;
protected String updateTableSql;
protected String existsSql;
@@ -422,6 +424,17 @@
this.fqnColumn = fqnColumn;
}
+ public boolean getUseSetBlob()
+ {
+ return useSetBlob;
+ }
+
+ public void setUseSetBlob(boolean useSetBlob)
+ {
+ testImmutability("useSetBlob");
+ this.useSetBlob = useSetBlob;
+ }
+
@Override
public void setProperties(Properties props)
{
@@ -453,6 +466,8 @@
this.createTable = prop == null ? CREATE_TABLE_DEFAULT : Boolean.valueOf(prop);
prop = props.getProperty("cache.jdbc.table.drop");
this.dropTable = prop == null ? DROP_TABLE_DEFAULT : Boolean.valueOf(prop);
+ prop = props.getProperty("cache.jdbc.node.useSetBlob");
+ this.useSetBlob = prop == null ? USE_SET_BLOB_DEFAULT : Boolean.valueOf(prop);
this.table = props.getProperty("cache.jdbc.table.name", TABLE_DEFAULT);
primaryKey = props.getProperty("cache.jdbc.table.primarykey", PRIMARY_KEY_DEFAULT);
@@ -633,4 +648,4 @@
{
return "INSERT INTO " + table + "_D VALUES ('x')";
}
-}
\ No newline at end of file
+}