diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java index 3642ca313..dd3b004bc 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingInfo.java @@ -683,7 +683,7 @@ public abstract class MappingInfo } type = dict.getJDBCType(tmplate.getJavaType(), size == -1, precis, - scale); + scale, tmplate.isXML()); } boolean ttype = true; diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java index f9baffcf2..49430931c 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/Column.java @@ -642,6 +642,15 @@ public class Column default: return false; } + case 2007: // Oracle-defined opaque type code for XMLType + switch (type) { + case Types.CHAR: + case Types.LONGVARCHAR: + case Types.VARCHAR: + return true; + default: + return false; + } default: return type == getType(); } diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index 2b3d1e553..2554faa1e 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -1486,6 +1486,15 @@ public class DBDictionary return getJDBCType(metaTypeCode, lob, 0, 0); } + /** + * Return the preferred {@link Types} constant for the given + * {@link JavaTypes} or {@link JavaSQLTypes} constant. + */ + public int getJDBCType(int metaTypeCode, boolean lob, int precis, + int scale, boolean xml) { + return getJDBCType(metaTypeCode, lob, precis, scale); + } + /** * Return the preferred {@link Types} constant for the given * {@link JavaTypes} or {@link JavaSQLTypes} constant. diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java index 7ce7ac323..8c245c571 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java @@ -41,6 +41,7 @@ import java.util.Set; import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; import org.apache.openjpa.jdbc.kernel.exps.FilterValue; +import org.apache.openjpa.jdbc.meta.JavaSQLTypes; import org.apache.openjpa.jdbc.schema.Column; import org.apache.openjpa.jdbc.schema.ForeignKey; import org.apache.openjpa.jdbc.schema.Index; @@ -51,6 +52,7 @@ import org.apache.openjpa.lib.jdbc.DelegatingDatabaseMetaData; import org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement; import org.apache.openjpa.lib.util.J2DoPrivHelper; import org.apache.openjpa.lib.util.Localizer; +import org.apache.openjpa.meta.JavaTypes; import org.apache.openjpa.util.StoreException; import org.apache.openjpa.util.UserException; @@ -873,6 +875,17 @@ public class OracleDictionary sql[0] += " CACHE " + seq.getAllocate(); return sql; } + + /** + * Return the preferred {@link Types} constant for the given + * {@link JavaTypes} or {@link JavaSQLTypes} constant. + */ + @Override + public int getJDBCType(int metaTypeCode, boolean lob, int precis, + int scale, boolean xml) { + return getJDBCType(metaTypeCode, lob && !xml, precis, scale); + } + protected String getSequencesSQL(String schemaName, String sequenceName) { StringBuffer buf = new StringBuffer();