Revision: 8286
http://datanucleus.svn.sourceforge.net/datanucleus/?rev=8286&view=rev
Author: andy_jefferson
Date: 2009-12-10 10:09:56 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
[NUCRDBMS-290] Mark BLOB/CLOB as not accepting length for Oracle
Modified Paths:
--------------
platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/DatabaseAdapter.java
platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/OracleAdapter.java
Modified: platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/DatabaseAdapter.java
===================================================================
--- platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/DatabaseAdapter.java 2009-12-10 10:06:06 UTC (rev 8285)
+++ platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/DatabaseAdapter.java 2009-12-10 10:09:56 UTC (rev 8286)
@@ -509,6 +509,28 @@
}
/**
+ * Accessor for the SQLType info for the specified JDBC type and the SQL type name.
+ * @param handler Schema handler
+ * @param mconn Connection
+ * @param jdbcTypeNumber JDBC type
+ * @return The SQL type info
+ */
+ protected Collection<SQLTypeInfo> getSQLTypeInfoForJdbcType(StoreSchemaHandler handler, ManagedConnection mconn,
+ short jdbcTypeNumber)
+ {
+ RDBMSTypesInfo types = (RDBMSTypesInfo)handler.getSchemaData(mconn.getConnection(), "types", null);
+
+ String key = "" + jdbcTypeNumber;
+ org.datanucleus.store.rdbms.schema.JDBCTypeInfo jdbcType =
+ (org.datanucleus.store.rdbms.schema.JDBCTypeInfo)types.getChild(key);
+ if (jdbcType == null)
+ {
+ return null;
+ }
+ return jdbcType.getChildren().values();
+ }
+
+ /**
* Convenience method for use by adapters to add their own fake JDBC/SQL types in where the
* JDBC driver doesn't provide some type.
* @param handler the schema handler managing the types
Modified: platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/OracleAdapter.java
===================================================================
--- platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/OracleAdapter.java 2009-12-10 10:06:06 UTC (rev 8285)
+++ platform/store.rdbms/trunk/src/java/org/datanucleus/store/rdbms/adapter/OracleAdapter.java 2009-12-10 10:09:56 UTC (rev 8286)
@@ -31,6 +31,8 @@
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.OMFContext;
@@ -178,6 +180,7 @@
SQLTypeInfo sqlType = new org.datanucleus.store.rdbms.schema.OracleTypeInfo(
"CLOB", (short)Types.CLOB, 1073741823, "'", "'", null, 1, true, (short)0,
false, false, false, "CLOB", (short)0, (short)0, 10);
+ sqlType.setAllowsPrecisionSpec(false); // Can't add precision on a CLOB
addSQLTypeForJDBCType(handler, mconn, (short)Types.CLOB, sqlType, true);
sqlType = new org.datanucleus.store.rdbms.schema.OracleTypeInfo(
@@ -206,6 +209,28 @@
1073741823, "'", "'", null, 1, true, (short)0,
false, false, false, OracleTypeInfo.TYPES_NAME_SYS_XMLTYPE, (short)0, (short)0, 10);
addSQLTypeForJDBCType(handler, mconn, (short)OracleTypeInfo.TYPES_SYS_XMLTYPE, sqlType, true);
+
+ // Update any types that need extra info relative to the JDBC info
+ Collection<SQLTypeInfo> sqlTypes = getSQLTypeInfoForJdbcType(handler, mconn, (short)Types.BLOB);
+ if (sqlTypes != null)
+ {
+ Iterator<SQLTypeInfo> iter = sqlTypes.iterator();
+ while (iter.hasNext())
+ {
+ sqlType = iter.next();
+ sqlType.setAllowsPrecisionSpec(false); // Can't add precision on a BLOB
+ }
+ }
+ sqlTypes = getSQLTypeInfoForJdbcType(handler, mconn, (short)Types.CLOB);
+ if (sqlType != null)
+ {
+ Iterator<SQLTypeInfo> iter = sqlTypes.iterator();
+ while (iter.hasNext())
+ {
+ sqlType = iter.next();
+ sqlType.setAllowsPrecisionSpec(false); // Can't add precision on a BLOB
+ }
+ }
}
public SQLTypeInfo newSQLTypeInfo(ResultSet rs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|