You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by st...@apache.org on 2019/01/10 12:31:24 UTC

[openjpa] branch master updated (08acaa4 -> aae0a95)

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git.


    from 08acaa4  OPENJPA-2753 add dbcp settings to Oracle Docker profile
     new c1d9fd3  OPENJPA-2768 fix XMLStore xml handling
     new d35ea4b  OPENJPA-2753 use an oracle12_xe docker container
     new aae0a95  OPENJPA-2761 properly handle javax.sql.Types.SQLXML

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/openjpa/jdbc/schema/Column.java     |   5 +-
 .../apache/openjpa/xmlstore/XMLFileHandler.java    | 150 ++++++++++-----------
 .../java/org/apache/openjpa/xmlstore/XMLStore.java |   8 +-
 .../apache/openjpa/xmlstore/XMLStoreManager.java   |  12 +-
 pom.xml                                            |   4 +-
 5 files changed, 87 insertions(+), 92 deletions(-)


[openjpa] 01/03: OPENJPA-2768 fix XMLStore xml handling

Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit c1d9fd3c62ab40a893749ac3338b3ed20ddd6567
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Jan 10 13:25:38 2019 +0100

    OPENJPA-2768 fix XMLStore xml handling
    
    the SAXParser handler didn't properly distinguish between 'extent' and 'element'
---
 .../apache/openjpa/xmlstore/XMLFileHandler.java    | 150 ++++++++++-----------
 .../java/org/apache/openjpa/xmlstore/XMLStore.java |   8 +-
 .../apache/openjpa/xmlstore/XMLStoreManager.java   |  12 +-
 3 files changed, 81 insertions(+), 89 deletions(-)

diff --git a/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java b/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java
index 16713f6..d8b1384 100644
--- a/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java
+++ b/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java
@@ -357,52 +357,49 @@ public class XMLFileHandler {
 
         private void startElement(String qName, Attributes attrs)
             throws Exception {
-            switch (qName.charAt(0)) {
-                case 'o': // object
-                    // get the metadata for the type we're reading
-                    String type = attrs.getValue("class");
-                    ClassMetaData meta = _conf.getMetaDataRepositoryInstance().
+
+            if ("object".equals(qName)) { // object
+                // get the metadata for the type we're reading
+                String type = attrs.getValue("class");
+                ClassMetaData meta = _conf.getMetaDataRepositoryInstance().
                         getMetaData(classForName(type), null, true);
 
-                    // construct the oid object
-                    Object oid;
-                    if (meta.getIdentityType() == ClassMetaData.ID_DATASTORE)
-                        oid = new Id(attrs.getValue("oid"), _conf, null);
-                    else
-                        oid = PCRegistry.newObjectId(meta.getDescribedType(),
+                // construct the oid object
+                Object oid;
+                if (meta.getIdentityType() == ClassMetaData.ID_DATASTORE)
+                    oid = new Id(attrs.getValue("oid"), _conf, null);
+                else
+                    oid = PCRegistry.newObjectId(meta.getDescribedType(),
                             attrs.getValue("oid"));
 
-                    // create an ObjectData that will contain the information
-                    // for this instance, and set the version
-                    _object = new ObjectData(oid, meta);
-                    _object.setVersion(new Long(attrs.getValue("version")));
-                    break;
-
-                case 'f': // field
-                    // start parsing a field element: for container types,
-                    // initialize the container; for other types, initialize a
-                    // buffer
-                    _fmd =
-                        _object.getMetaData().getField(attrs.getValue("name"));
-                    switch (_fmd.getTypeCode()) {
-                        case JavaTypes.COLLECTION:
-                        case JavaTypes.ARRAY:
-                            _fieldVal = new ArrayList();
-                            break;
-                        case JavaTypes.MAP:
-                            _fieldVal = new HashMap();
-                            break;
-                        default:
-                            _buf = new StringBuffer();
-                    }
-                    break;
+                // create an ObjectData that will contain the information
+                // for this instance, and set the version
+                _object = new ObjectData(oid, meta);
+                _object.setVersion(new Long(attrs.getValue("version")));
+            }
+            else if ("field".equals(qName)) { // field
+                // start parsing a field element: for container types,
+                // initialize the container; for other types, initialize a
+                // buffer
+                _fmd = _object.getMetaData().getField(attrs.getValue("name"));
+                switch (_fmd.getTypeCode()) {
+                    case JavaTypes.COLLECTION:
+                    case JavaTypes.ARRAY:
+                        _fieldVal = new ArrayList();
+                        break;
+                    case JavaTypes.MAP:
+                        _fieldVal = new HashMap();
+                        break;
+                    default:
+                        _buf = new StringBuffer();
+                }
+            }
+            else if ("element".equals(qName) ||
+                     "key".equals(qName)     ||
+                     "value".equals(qName) ) { // field
 
-                case 'e': // element
-                case 'k': // key
-                case 'v': // value
                     // initialize a buffer for the element value
                     _buf = new StringBuffer();
-                    break;
             }
         }
 
@@ -411,7 +408,7 @@ public class XMLFileHandler {
             throws SAXException {
             try {
                 endElement(qName);
-            } catch (RuntimeException re) {
+                } catch (RuntimeException re) {
                 throw re;
             } catch (SAXException se) {
                 throw se;
@@ -423,49 +420,44 @@ public class XMLFileHandler {
         private void endElement(String qName)
             throws Exception {
             Object val;
-            switch (qName.charAt(0)) {
-                case 'o': // object
-                    // add the object to our results
-                    _extent.add(_object);
-
-                case 'f': // field
-                    switch (_fmd.getTypeCode()) {
-                        case JavaTypes.COLLECTION:
-                        case JavaTypes.ARRAY:
-                        case JavaTypes.MAP:
-                            // field value already constructed
-                            break;
-                        default:
-                            // construct the field value from text within the
-                            // element
-                            _fieldVal = fromXMLString(_fmd.getTypeCode(),
+            if ("object".equals(qName)) {
+                // add the object to our results
+                _extent.add(_object);
+            }
+            else if ("field".equals(qName)) {
+                switch (_fmd.getTypeCode()) {
+                    case JavaTypes.COLLECTION:
+                    case JavaTypes.ARRAY:
+                    case JavaTypes.MAP:
+                        // field value already constructed
+                        break;
+                    default:
+                        // construct the field value from text within the
+                        // element
+                        _fieldVal = fromXMLString(_fmd.getTypeCode(),
                                 _fmd.getTypeMetaData(), _buf.toString());
-                    }
-
-                    // set the field value into the object being parsed
-                    _object.setField(_fmd.getIndex(), _fieldVal);
-                    break;
+                }
 
-                case 'e': // element
-                    // cache element value
-                    val = fromXMLString(_fmd.getElement().getTypeCode(),
+                // set the field value into the object being parsed
+                _object.setField(_fmd.getIndex(), _fieldVal);
+            }
+            else if ("element".equals(qName)) {
+                // cache element value
+                val = fromXMLString(_fmd.getElement().getTypeCode(),
                         _fmd.getElement().getTypeMetaData(), _buf.toString());
-                    ((Collection) _fieldVal).add(val);
-                    break;
-
-                case 'k': // key
-                    // cache key value
-                    _keyVal = fromXMLString(_fmd.getKey().getTypeCode(),
+                ((Collection) _fieldVal).add(val);
+            }
+            else if ("key".equals(qName)) {
+                // cache key value
+                _keyVal = fromXMLString(_fmd.getKey().getTypeCode(),
                         _fmd.getKey().getTypeMetaData(), _buf.toString());
-                    break;
-
-                case 'v': // value
-                    // create value and put cached key and value into map
-                    val = fromXMLString(_fmd.getElement().getTypeCode(),
-                        _fmd.getElement().getTypeMetaData(), _buf.toString());
-                    Map map = (Map) _fieldVal;
-                    map.put(_keyVal, val);
-                    break;
+            }
+            else if ("value".equals(qName)) {
+                // create value and put cached key and value into map
+                val = fromXMLString(_fmd.getElement().getTypeCode(),
+                    _fmd.getElement().getTypeMetaData(), _buf.toString());
+                Map map = (Map) _fieldVal;
+                map.put(_keyVal, val);
             }
 
             // don't cache text between elements
diff --git a/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStore.java b/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStore.java
index bd1873c..7cc330f 100644
--- a/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStore.java
+++ b/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStore.java
@@ -118,8 +118,8 @@ public class XMLStore {
      * @param updates {@link ObjectData} instances to insert or update
      * @param deletes {@link ObjectData} instances to delete
      */
-    public synchronized void endTransaction(Collection updates,
-        Collection deletes) {
+    public synchronized void endTransaction(Collection<ObjectData> updates,
+                                            Collection<ObjectData> deletes) {
         // track dirty types
         Set dirty = new HashSet();
         try {
@@ -154,6 +154,6 @@ public class XMLStore {
             // unlock store
             notify();
             _locked = false;
-		}
-	}
+        }
+    }
 }
diff --git a/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStoreManager.java b/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStoreManager.java
index be9603e..5562c98 100644
--- a/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStoreManager.java
+++ b/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLStoreManager.java
@@ -51,8 +51,8 @@ public class XMLStoreManager
     private XMLStore _store;
 
     // changed data within the current transaction
-    private Collection _updates;
-    private Collection _deletes;
+    private Collection<ObjectData> _updates;
+    private Collection<ObjectData> _deletes;
 
     @Override
     protected Collection getUnsupportedOptions() {
@@ -201,8 +201,8 @@ public class XMLStoreManager
     }
 
     @Override
-    protected Collection flush(Collection pNew, Collection pNewUpdated,
-        Collection pNewFlushedDeleted, Collection pDirty, Collection pDeleted) {
+    protected Collection flush(Collection<OpenJPAStateManager> pNew, Collection<OpenJPAStateManager> pNewUpdated,
+        Collection<OpenJPAStateManager> pNewFlushedDeleted, Collection<OpenJPAStateManager> pDirty, Collection<OpenJPAStateManager> pDeleted) {
         // we don't support incremental flushing, so pNewUpdated and
         // pNewFlushedDeleted should be empty; we ignore them here
 
@@ -210,8 +210,8 @@ public class XMLStoreManager
         Collection exceps = new LinkedList();
 
         // convert instances to ObjectDatas
-        _updates = new ArrayList(pNew.size() + pDirty.size());
-        _deletes = new ArrayList(pDeleted.size());
+        _updates = new ArrayList<>(pNew.size() + pDirty.size());
+        _deletes = new ArrayList<>(pDeleted.size());
 
         // convert additions
         for (Iterator itr = pNew.iterator(); itr.hasNext();) {


[openjpa] 03/03: OPENJPA-2761 properly handle javax.sql.Types.SQLXML

Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit aae0a95f6c8f38e0df18e5f538761ee502d9eb08
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Jan 10 13:29:49 2019 +0100

    OPENJPA-2761 properly handle javax.sql.Types.SQLXML
---
 .../src/main/java/org/apache/openjpa/jdbc/schema/Column.java         | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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 65ac62d..35b02a6 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
@@ -766,7 +766,8 @@ public class Column extends ReferenceCounter {
                     default:
                         return false;
                 }
-            case 2007:  // Oracle-defined opaque type code for XMLType
+            case Types.SQLXML:  // All XML Types
+            case 2007:          // Oracle-defined opaque type code for XMLType treated the same way
                 switch (type) {
                     case Types.CHAR:
                     case Types.LONGVARCHAR:
@@ -778,6 +779,8 @@ public class Column extends ReferenceCounter {
                          return false;
                 }
 
+
+
             default:
                 return type == getType();
         }


[openjpa] 02/03: OPENJPA-2753 use an oracle12_xe docker container

Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit d35ea4bb06d103766c4cd1e738b265d69b8a4f36
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Jan 10 13:27:42 2019 +0100

    OPENJPA-2753 use an oracle12_xe docker container
    
    It seems Oracle11 had really a problem with XMLType handling internally.
    It did seemingly random return a 0x00 at position 4000 of a xmltype.
    This got fixed in Oracle12
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9cc1559..c1cc1ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1401,7 +1401,7 @@
                 <oracle.artifactid>ojdbc6</oracle.artifactid>
                 <oracle.version>11.2.0.4.0-atlassian-hosted</oracle.version>
 
-                <oracle.server.version>16.04</oracle.server.version>
+                <oracle.server.version>latest</oracle.server.version>
                 <docker.external.oracle.port>1521</docker.external.oracle.port>
 
                 <connection.driver.name>oracle.jdbc.driver.OracleDriver</connection.driver.name>
@@ -1454,7 +1454,7 @@
                         <configuration>
                             <images>
                                 <image>
-                                    <name>wnameless/oracle-xe-11g:${oracle.server.version}</name>
+                                    <name>sath89/oracle-12c:${oracle.server.version}</name>
                                     <run>
                                         <volumes>
                                             <bind>