[exo-jcr-commits] exo-jcr SVN: r3630 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Dec 9 05:28:28 EST 2010
Author: tolusha
Date: 2010-12-09 05:28:27 -0500 (Thu, 09 Dec 2010)
New Revision: 3630
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializer.java
Log:
EXOJCR-1078: fix RDBMS for HSQLDB
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializer.java 2010-12-09 08:57:47 UTC (rev 3629)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RdbmsWorkspaceInitializer.java 2010-12-09 10:28:27 UTC (rev 3630)
@@ -121,15 +121,14 @@
public static final byte LONG_LEN = 3;
/**
- * Indicates the way to set value thru setBinaryStream() method.
+ * Generic dialect.
*/
- public static final int SET_BINARY_STREAM_METHOD = 0;
+ public static final int DB_DIALECT_GENERIC = DBConstants.DB_DIALECT_GENERIC.hashCode();
/**
- * Indicates the way to set value thru setString() method.
+ * HSQLDB dialect.
*/
- public static final int SET_STRING_METHOD = 1;
-
+ public static final int DB_DIALECT_HSQLDB = DBConstants.DB_DIALECT_HSQLDB.hashCode();
/**
* List of temporary files.
*/
@@ -517,14 +516,8 @@
PreparedStatement insertNode = null;
- int setValueMethod = SET_BINARY_STREAM_METHOD;
+ int dialect = DialectDetecter.detect(jdbcConn.getMetaData()).hashCode();
- String dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
- if (dbDialect.equals(DBConstants.DB_DIALECT_HSQLDB))
- {
- setValueMethod = SET_STRING_METHOD;
- }
-
try
{
contentReader =
@@ -611,17 +604,25 @@
String value = new String(readBuffer);
insertNode.setBoolean(i + 1, value.equals("t"));
}
- else
+ else
{
- if (setValueMethod == SET_STRING_METHOD)
+ if (dialect == DB_DIALECT_HSQLDB)
{
- byte[] buf = new byte[(int) len];
- stream.read(buf);
- insertNode.setString(i + 1, new String(buf, Constants.DEFAULT_ENCODING));
+ if (columnType[i] == Types.VARBINARY)
+ {
+ insertNode.setBinaryStream(i + 1, stream, (int)len);
+ }
+ else
+ {
+ byte[] readBuffer = new byte[(int)len];
+ stream.read(readBuffer);
+
+ insertNode.setString(i + 1, new String(readBuffer, Constants.DEFAULT_ENCODING));
+ }
}
else
{
- insertNode.setBinaryStream(i + 1, stream, (int) len);
+ insertNode.setBinaryStream(i + 1, stream, (int)len);
}
}
}
More information about the exo-jcr-commits
mailing list