openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wisnes...@apache.org
Subject svn commit: r547831 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java OracleDictionary.java SQLServerDictionary.java SelectImpl.java
Date Fri, 15 Jun 2007 23:44:48 GMT
Author: wisneskid
Date: Fri Jun 15 16:44:47 2007
New Revision: 547831

URL: http://svn.apache.org/viewvc?view=rev&rev=547831
Log:
OPENJPA-240 Feature:Persistent field mapping support for XML column type.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=547831&r1=547830&r2=547831
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Fri Jun 15 16:44:47 2007
@@ -207,6 +207,8 @@
 	    		supportsLockingWithInnerJoin = true;
 	    		supportsLockingWithOuterJoin = true;
 	    		forUpdateClause = "WITH RR USE AND KEEP UPDATE LOCKS";
+	    		if (maj >=9)
+	    		    supportsXMLColumn = true;
 	    	}
 
             if (metaData.getDatabaseProductVersion().indexOf("DSN") != -1) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=547831&r1=547830&r2=547831
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Fri Jun 15 16:44:47 2007
@@ -212,6 +212,7 @@
     public boolean requiresCastForMathFunctions = false;
     public boolean requiresCastForComparisons = false;
     public boolean supportsModOperator = false;
+    public boolean supportsXMLColumn = false;
 
     // functions
     public String castFunction = "CAST({0} AS {1})";
@@ -273,6 +274,8 @@
     public String tinyintTypeName = "TINYINT";
     public String varbinaryTypeName = "VARBINARY";
     public String varcharTypeName = "VARCHAR";
+    public String xmlTypeName = "XML";
+    public String getStringVal = "";
 
     // schema metadata
     public boolean useSchemaName = true;

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java?view=diff&rev=547831&r1=547830&r2=547831
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/OracleDictionary.java
Fri Jun 15 16:44:47 2007
@@ -130,6 +130,8 @@
             "CTXSYS", "MDSYS", "SYS", "SYSTEM", "WKSYS", "WMSYS", "XDB",
         }));
 
+        supportsXMLColumn = true;
+        xmlTypeName = "XMLType";
         bigintTypeName = "NUMBER{0}";
         bitTypeName = "NUMBER{0}";
         decimalTypeName = "NUMBER{0}";
@@ -182,15 +184,23 @@
                 driverVendor = VENDOR_ORACLE + meta.getDriverMajorVersion()
                     + meta.getDriverMinorVersion();
 
+                String productVersion = meta.getDatabaseProductVersion()
+                    .split("Release ",0)[1].split("\\.",0)[0];
+                int release = Integer.parseInt(productVersion);
+                
                 // warn sql92
-                if (meta.getDatabaseProductVersion().indexOf("Release 8.") > 0)
-                {
+                if (release == 8) {
                     if (joinSyntax == SYNTAX_SQL92 && log.isWarnEnabled())
                         log.warn(_loc.get("oracle-syntax"));
                     joinSyntax = SYNTAX_DATABASE;
                     dateTypeName = "DATE"; // added oracle 9
                     timestampTypeName = "DATE"; // added oracle 9
+                    supportsXMLColumn = false;
                 }
+                else 
+                    // select of an xml column requires ".getStringVal()"
+                    // suffix. eg. t0.xmlcol.getStringVal()
+                    getStringVal = ".getStringVal()";
             } else if (metadataClassName.startsWith("com.ddtek.")
                 || url.indexOf("jdbc:datadirect:oracle:") != -1
                 || "Oracle".equals(driverName)) {
@@ -499,7 +509,8 @@
         throws SQLException {
         if (colType == Types.BLOB && _driverBehavior == BEHAVE_ORACLE)
             stmnt.setBlob(idx, getEmptyBlob());
-        else if (colType == Types.CLOB && _driverBehavior == BEHAVE_ORACLE)
+        else if (colType == Types.CLOB && _driverBehavior == BEHAVE_ORACLE
+            && !col.isXML())
             stmnt.setClob(idx, getEmptyClob());
         else if ((colType == Types.STRUCT || colType == Types.OTHER)
             && col != null && col.getTypeName() != null)
@@ -509,7 +520,7 @@
         else if (colType == Types.DATE)
             super.setNull(stmnt, idx, Types.TIMESTAMP, col);
         // the Oracle driver does not support Types.OTHER with setNull
-        else if (colType == Types.OTHER)
+        else if (colType == Types.OTHER || col.isXML())
             super.setNull(stmnt, idx, Types.NULL, col);
         else
             super.setNull(stmnt, idx, colType, col);

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java?view=diff&rev=547831&r1=547830&r2=547831
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLServerDictionary.java
Fri Jun 15 16:44:47 2007
@@ -79,6 +79,9 @@
                     driverVendor = VENDOR_OTHER;
             } else
                 driverVendor = VENDOR_OTHER;
+            if (driverName.contains(platform) && Integer.parseInt(driverName
+                .split("Server ",0)[1].split(" ")[0]) >= 2005)
+                supportsXMLColumn = true;
         }
 
         // warn about using cursors

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?view=diff&rev=547831&r1=547830&r2=547831
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Fri
Jun 15 16:44:47 2007
@@ -189,6 +189,7 @@
         _conf = conf;
         _dict = _conf.getDBDictionaryInstance();
         _joinSyntax = _dict.joinSyntax;
+        _selects._dict = _dict;
     }
 
     /////////////////////////////////
@@ -2661,6 +2662,7 @@
         private List _idents = null;
         private Map _aliases = null;
         private Map _selectAs = null;
+        private DBDictionary _dict = null;
 
         /**
          * Add all aliases from another instance.
@@ -2769,6 +2771,9 @@
                     Object id = (ident && _idents != null) ? _idents.get(i)
                         : _ids.get(i);
                     Object alias = _aliases.get(id);
+                    if (id instanceof Column && ((Column)id).isXML())
+                        alias = alias + _dict.getStringVal;
+                        
                     String as = null;
                     if (inner)
                         as = ((String) alias).replace('.', '_');



Mime
View raw message