Author: dereed
Date: 2011-12-09 17:59:23 -0500 (Fri, 09 Dec 2011)
New Revision: 8472
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
Log:
[JBCACHE-1610] Add cache.jdbc.node.useSetBlob cache loader flag to work around problems in
Oracle driver and Blobs
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2011-10-06
23:35:01 UTC (rev 8471)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2011-12-09
22:59:23 UTC (rev 8472)
@@ -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/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2011-10-06
23:35:01 UTC (rev 8471)
+++
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2011-12-09
22:59:23 UTC (rev 8472)
@@ -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
+}