openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1102329 - in /openjpa/sandboxes/perf-2.1.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/ openjpa-persistence-jdbc/src/test/resources/org/apache/openjp...
Date Thu, 12 May 2011 14:42:59 GMT
Author: curtisr7
Date: Thu May 12 14:42:59 2011
New Revision: 1102329

URL: http://svn.apache.org/viewvc?rev=1102329&view=rev
Log:
OPENJPA-1989: merge to sandbox.

Modified:
    openjpa/sandboxes/perf-2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
    openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestToOneLazyXmlOverride.java
    openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideToOneEntity.java
    openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/toone-orm.xml
    openjpa/sandboxes/perf-2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java

Modified: openjpa/sandboxes/perf-2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf-2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java?rev=1102329&r1=1102328&r2=1102329&view=diff
==============================================================================
--- openjpa/sandboxes/perf-2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
(original)
+++ openjpa/sandboxes/perf-2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
Thu May 12 14:42:59 2011
@@ -459,7 +459,7 @@ public class JDBCStoreManager 
                 }
                 Object coll =  owner.fetchObject(fms[i].getIndex());
                 if (coll instanceof Map)
-                    coll = ((Map)coll).values();
+                    coll = ((Map<?,?>)coll).values();
                 if (coll instanceof Collection<?> && 
                     ((Collection<?>) coll).size() > 0) {
                     // Found eagerly loaded collection.
@@ -594,7 +594,7 @@ public class JDBCStoreManager 
 
         Union union = _sql.newUnion(mappings.length);
         union.setExpectedResultCount(1, false);
-        if (fetch.getSubclassFetchMode(mapping) != fetch.EAGER_JOIN)
+        if (fetch.getSubclassFetchMode(mapping) != EagerFetchModes.EAGER_JOIN)
             union.abortUnion();
         union.select(new Union.Selector() {
             public void select(Select sel, int i) {
@@ -823,7 +823,7 @@ public class JDBCStoreManager 
 
         ResultObjectProvider[] rops = null;
         final JDBCFetchConfiguration jfetch = (JDBCFetchConfiguration) fetch;
-        if (jfetch.getSubclassFetchMode(mapping) != jfetch.EAGER_JOIN)
+        if (jfetch.getSubclassFetchMode(mapping) != EagerFetchModes.EAGER_JOIN)
             rops = new ResultObjectProvider[mappings.length];
 
         try {
@@ -1232,15 +1232,15 @@ public class JDBCStoreManager 
         int mode;
         for (int i = 0; i < fms.length; i++) {
             mode = fms[i].getEagerFetchMode();
-            if (mode == fetch.EAGER_NONE)
+            if (mode == EagerFetchModes.EAGER_NONE)
                 continue;
             if (!requiresSelect(fms[i], sm, fields, fetch))
                 continue;
 
             // try to select with join first
-            jtype = (fms[i].getNullValue() == fms[i].NULL_EXCEPTION) 
-                ? sel.EAGER_INNER : sel.EAGER_OUTER;
-            if (mode != fetch.EAGER_PARALLEL && !fms[i].isEagerSelectToMany()
+            jtype = (fms[i].getNullValue() == FieldMetaData.NULL_EXCEPTION) 
+                ? Select.EAGER_INNER : Select.EAGER_OUTER;
+            if (mode != EagerFetchModes.EAGER_PARALLEL && !fms[i].isEagerSelectToMany()
                 && fms[i].supportsSelect(sel, jtype, sm, this, fetch) > 0
                 && sel.eagerClone(fms[i], jtype, false, 1) != null)
                 continue;
@@ -1252,8 +1252,8 @@ public class JDBCStoreManager 
             // to use a to-many join also.  currently we limit eager
             // outer joins to non-LRS, non-ranged selects that don't already
             // have an eager to-many join
-            if ((hasJoin || mode == fetch.EAGER_JOIN 
-                || (mode == fetch.DEFAULT && sm != null))
+            if ((hasJoin || mode == EagerFetchModes.EAGER_JOIN 
+                || (mode == FetchConfiguration.DEFAULT && sm != null))
                 && fms[i].isEagerSelectToMany()
                 && !inEagerJoin
                 && !sel.hasEagerJoin(true)
@@ -1268,8 +1268,8 @@ public class JDBCStoreManager 
             }
 
             // finally, try parallel
-            if (eager == fetch.EAGER_PARALLEL
-                && (sels = fms[i].supportsSelect(sel, sel.EAGER_PARALLEL, sm,
+            if (eager == EagerFetchModes.EAGER_PARALLEL
+                && (sels = fms[i].supportsSelect(sel, Select.EAGER_PARALLEL, sm,
                 this, fetch)) != 0)
                 sel.eagerClone(fms[i], Select.EAGER_PARALLEL, 
                     fms[i].isEagerSelectToMany(), sels);
@@ -1372,7 +1372,7 @@ public class JDBCStoreManager 
                 seld = Math.max(fseld, seld);
             } else if (optSelect(fms[i], sel, sm, fetch)) {
                 fseld = fms[i].select(sel, sm, this, 
-                	fetch.traverseJDBC(fms[i]), fetch.EAGER_NONE);
+                	fetch.traverseJDBC(fms[i]), EagerFetchModes.EAGER_NONE);
 
                 // don't upgrade seld to > 0 based on these fields, since
                 // they're not in the calculated field set
@@ -1412,10 +1412,10 @@ public class JDBCStoreManager 
     private boolean optSelect(FieldMapping fm, Select sel,
         OpenJPAStateManager sm, JDBCFetchConfiguration fetch) {
         return !fm.isInDefaultFetchGroup() 
-            && !fm.isDefaultFetchGroupExplicit()
+             && !fm.isDefaultFetchGroupExplicit()
             && (sm == null || sm.getPCState() == PCState.TRANSIENT 
             || !sm.getLoaded().get(fm.getIndex()))
-            && fm.supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, fetch) > 0;
+            && fm.supportsSelect(sel, Select.TYPE_TWO_PART, sm, this, fetch) >
0;
     }
 
     /**
@@ -1458,7 +1458,7 @@ public class JDBCStoreManager 
             	if (fetch.requiresFetch(fms[j]) != FetchConfiguration.FETCH_LOAD
                     && ((!fms[j].isInDefaultFetchGroup() 
                     && fms[j].isDefaultFetchGroupExplicit())
-                    || fms[j].supportsSelect(sel, sel.TYPE_TWO_PART, sm, this, 
+                    || fms[j].supportsSelect(sel, Select.TYPE_TWO_PART, sm, this, 
                     fetch) <= 0)) 
             		continue;
 
@@ -1472,10 +1472,8 @@ public class JDBCStoreManager 
                 }
 
                 // if can select with tables already selected, do it
-                if (fms[j].supportsSelect(sel, sel.TYPE_JOINLESS, sm, this,
-                    fetch) > 0)
-                    fms[j].select(sel, null, this, fetch.traverseJDBC(fms[j]),
-                        fetch.EAGER_NONE);
+                if (fms[j].supportsSelect(sel, Select.TYPE_JOINLESS, sm, this, fetch) >
0)
+                    fms[j].select(sel, null, this, fetch.traverseJDBC(fms[j]), EagerFetchModes.EAGER_NONE);
             }
         }
     }

Modified: openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestToOneLazyXmlOverride.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestToOneLazyXmlOverride.java?rev=1102329&r1=1102328&r2=1102329&view=diff
==============================================================================
--- openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestToOneLazyXmlOverride.java
(original)
+++ openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/TestToOneLazyXmlOverride.java
Thu May 12 14:42:59 2011
@@ -47,11 +47,17 @@ public class TestToOneLazyXmlOverride ex
             resetSQL();
 
             em.find(XmlOverrideToOneEntity.class, x.getId());
-            for (String lastSql : sql) {
-                // Make sure we don't have any joins!
-                assertFalse("Shouldn't have found any instances of join or JOIN in last sql,
but did. Last SQL = "
-                    + lastSql, lastSql.contains("join") || lastSql.contains("JOIN"));
-            }
+
+            assertTrue(sql.size() == 1);
+            String lastSql = sql.get(0);
+            // Make sure we don't have any joins!
+            assertFalse("Shouldn't have found any instances of join or JOIN in last sql,
but did. Last SQL = "
+                + lastSql, lastSql.contains("join") || lastSql.contains("JOIN"));
+
+            // Make sure that we selected lazy join columns.
+            assertTrue(lastSql.contains("o2o"));
+            assertTrue(lastSql.contains("m2o"));
+
         } finally {
             if (em.getTransaction().isActive()) {
                 em.getTransaction().rollback();

Modified: openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideToOneEntity.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideToOneEntity.java?rev=1102329&r1=1102328&r2=1102329&view=diff
==============================================================================
--- openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideToOneEntity.java
(original)
+++ openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/xml/XmlOverrideToOneEntity.java
Thu May 12 14:42:59 2011
@@ -19,12 +19,16 @@
  */
 package org.apache.openjpa.persistence.xml;
 
+import java.util.List;
+
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
+import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
 import javax.persistence.OneToOne;
+import javax.persistence.Version;
 
 @Entity
 public class XmlOverrideToOneEntity {
@@ -32,12 +36,17 @@ public class XmlOverrideToOneEntity {
     @GeneratedValue(strategy = GenerationType.AUTO)
     int id;
 
-    @OneToOne 
+    @OneToOne
+    @JoinColumn(name="o2o")
     XmlOverrideToOneEntity otherO2O;
 
     @ManyToOne
+    @JoinColumn(name="m2o")
     XmlOverrideToOneEntity otherM2O;
-
+    
+    @Version
+    int version;
+    
     public long getId() {
         return id;
     }

Modified: openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/toone-orm.xml
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/toone-orm.xml?rev=1102329&r1=1102328&r2=1102329&view=diff
==============================================================================
--- openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/toone-orm.xml
(original)
+++ openjpa/sandboxes/perf-2.1.x/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/xml/toone-orm.xml
Thu May 12 14:42:59 2011
@@ -25,8 +25,10 @@
 	<entity name="XmlOverrideToOneEntity" class="XmlOverrideToOneEntity">
 		<attributes>
 			<many-to-one name="otherM2O" fetch="LAZY">
+				<join-column name="m2o"/>
 			</many-to-one>
 			<one-to-one name="otherO2O" fetch="LAZY">
+				<join-column name="o2o"/>
 			</one-to-one>
 		</attributes>
 	</entity>

Modified: openjpa/sandboxes/perf-2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/perf-2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=1102329&r1=1102328&r2=1102329&view=diff
==============================================================================
--- openjpa/sandboxes/perf-2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
(original)
+++ openjpa/sandboxes/perf-2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
Thu May 12 14:42:59 2011
@@ -1463,11 +1463,14 @@ public class XMLPersistenceMetaDataParse
     protected void parseOneToOne(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
         String val = attrs.getValue("fetch");
-        if (val == null) {
-            fmd.setInDefaultFetchGroup(true);
-        } else {
-            fmd.setInDefaultFetchGroup("EAGER".equals(val));
-        }
+        boolean dfg = (val != null && val.equals("LAZY")) ? false : true;
+        
+        // We need to toggle the DFG explicit flag here because this is used for an optimization
when selecting an
+        // Entity with lazy fields. 
+        fmd.setDefaultFetchGroupExplicit(true);
+        fmd.setInDefaultFetchGroup(dfg);
+        fmd.setDefaultFetchGroupExplicit(false);
+        
         val = attrs.getValue("target-entity");
         if (val != null)
             fmd.setTypeOverride(AnnotationPersistenceMetaDataParser.toOverrideType(classForName(val)));
@@ -1487,11 +1490,14 @@ public class XMLPersistenceMetaDataParse
     protected void parseManyToOne(FieldMetaData fmd, Attributes attrs)
         throws SAXException {
         String val = attrs.getValue("fetch");
-        if (val == null) {
-            fmd.setInDefaultFetchGroup(true);
-        } else {
-            fmd.setInDefaultFetchGroup("EAGER".equals(val));
-        }
+        boolean dfg = (val != null && val.equals("LAZY")) ? false : true;
+        
+        // We need to toggle the DFG explicit flag here because this is used for an optimization
when selecting an
+        // Entity with lazy fields. 
+        fmd.setDefaultFetchGroupExplicit(true);
+        fmd.setInDefaultFetchGroup(dfg);
+        fmd.setDefaultFetchGroupExplicit(false);
+        
         val = attrs.getValue("target-entity");
         if (val != null)
             fmd.setTypeOverride(AnnotationPersistenceMetaDataParser.toOverrideType(classForName(val)));



Mime
View raw message