You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by kw...@apache.org on 2007/11/01 23:36:10 UTC
svn commit: r591157 - in /openjpa/branches/1.0.x:
openjpa-kernel/src/main/java/org/apache/openjpa/kernel/
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fetchgroups/
Author: kwsutter
Date: Thu Nov 1 15:36:09 2007
New Revision: 591157
URL: http://svn.apache.org/viewvc?rev=591157&view=rev
Log:
OPENJPA-370. Backing out the changes for the LoadFetchGroup implementation. We need to re-think the implementation (both the real and the expected). I left the test Entities in SVN, but removed the testcase so that we wouldn't fail the builds.
Removed:
openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/fetchgroups/TestFetchGroup.java
Modified:
openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java?rev=591157&r1=591156&r2=591157&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingFetchConfiguration.java Thu Nov 1 15:36:09 2007
@@ -18,7 +18,6 @@
*/
package org.apache.openjpa.kernel;
-import java.util.BitSet;
import java.util.Collection;
import java.util.Set;
@@ -447,15 +446,7 @@
throw translate(re);
}
}
-
- public BitSet requiresFetch(Set fgs, FieldMetaData[] fmds ){
- try {
- return _fetch.requiresFetch(fgs, fmds);
- } catch (RuntimeException re) {
- throw translate(re);
- }
- }
-
+
public boolean requiresLoad() {
try {
return _fetch.requiresLoad();
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java?rev=591157&r1=591156&r2=591157&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfiguration.java Thu Nov 1 15:36:09 2007
@@ -19,7 +19,6 @@
package org.apache.openjpa.kernel;
import java.io.Serializable;
-import java.util.BitSet;
import java.util.Collection;
import java.util.Set;
@@ -346,18 +345,6 @@
*/
public int requiresFetch(FieldMetaData fm);
- /**
- * Affirms if the given fields require to be fetched in the context of
- * the given fetch group set. Returns a BitSet that contains one of
- * {@link #FETCH_NONE}, {@link #FETCH_LOAD}, {@link FETCH_REF} for each
- * field.
- *
- * @param fgs fetch group set
- * @param fmds array of fields to be examined
- * @return BitSet that indicates whether fetches are required or not
- */
- public BitSet requiresFetch(Set fgs, FieldMetaData[] fmds );
-
/**
* Return false if we know that the object being fetched with this
* configuration does not require a load, because this configuration came
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java?rev=591157&r1=591156&r2=591157&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FetchConfigurationImpl.java Thu Nov 1 15:36:09 2007
@@ -21,7 +21,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -93,7 +92,6 @@
private boolean _load = true;
private int _availableRecursion;
private int _availableDepth;
- private Map _lfgFields = null;
public FetchConfigurationImpl() {
this(null);
@@ -512,10 +510,6 @@
if (!includes(fm))
return FETCH_NONE;
- return indirectFetch(fm);
- }
-
- private int indirectFetch(FieldMetaData fm){
Class type = getRelationType(fm);
if (type == null)
return FETCH_LOAD;
@@ -535,15 +529,6 @@
return FETCH_REF;
return FETCH_LOAD;
}
-
- public BitSet requiresFetch(Set fgs, FieldMetaData[] fmds) {
- BitSet fields = new BitSet(fgs.size());
- Iterator itr = fgs.iterator();
- while (itr.hasNext()) {
- fields = includes((FieldMetaData) itr.next(), fmds, fields);
- }
- return fields;
- }
public boolean requiresLoad() {
return _load;
@@ -582,73 +567,16 @@
|| hasField(fmd.getFullName(false)))
return true;
String[] fgs = fmd.getCustomFetchGroups();
- for (int i = 0; i < fgs.length; i++){
+ for (int i = 0; i < fgs.length; i++)
if (hasFetchGroup(fgs[i]))
return true;
- }
return false;
}
- private BitSet includes(FieldMetaData fmd, FieldMetaData[] fmds,
- BitSet fields) {
- if ((fmd.isInDefaultFetchGroup() && hasFetchGroup(FetchGroup.NAME_DEFAULT))
- || hasFetchGroup(FetchGroup.NAME_ALL)
- || hasField(fmd.getFullName(false))) {
- if (indirectFetch(fmd) != FETCH_NONE)
- fields.set(fmd.getIndex());
- return fields;
- }
- // now we need to see if this field associates with
- // any fetch groups
- String[] fgs = fmd.getCustomFetchGroups();
- for (int i = 0; i < fgs.length; i++) {
- if (hasFetchGroup(fgs[i])) {
- if (indirectFetch(fmd) != FETCH_NONE)
- fields.set(fmd.getIndex());
- // check whether this field has a loadFetchGroup
- // if it has a LoadFetchGroup, then we need to get
- // all the fields that associate with this LoadFetchGroup
- String fg = fmd.getLoadFetchGroup();
- if (fg != null) {
- BitSet fldIndex = getLoadFetchGroupFields(fg, fmds);
- // merge the loadFetchGroup fields to the retuned fields.
- if (fldIndex != null && !fldIndex.isEmpty()) {
- for (int j = 0; j < fldIndex.length(); j++)
- if (fldIndex.get(j))
- fields.set(j);
- }
- }
- }
- }
- return fields;
- }
-
- /**
- * Search the fields for this loadFetchGroup. It basically searches from
- * each field and check whether this field has the same fetchgroup. If it
- * has then this field is required to load.
- */
- private BitSet getLoadFetchGroupFields(String fg, FieldMetaData[] fmds) {
- BitSet rtnField = null;
- if (_lfgFields != null && _lfgFields.containsKey(fg))
- return (BitSet)_lfgFields.get(fg);
- for (int i = 0; i < fmds.length; i++) {
- if (fmds[i].isInFetchGroup(fg)){
- if (rtnField == null)
- rtnField = new BitSet(fmds.length);
- rtnField.set(i);
- }
- }
- if (_lfgFields == null)
- _lfgFields = new HashMap(fmds.length);
- _lfgFields.put(fg,rtnField);
- return rtnField;
- }
-
/**
- * Return the available recursion depth via the given field for the
+ * Return the available recursion depth via the given field for the
* given type.
- *
+ *
* @param traverse whether we're traversing the field
*/
private int getAvailableRecursionDepth(FieldMetaData fm, Class type,
Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?rev=591157&r1=591156&r2=591157&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java Thu Nov 1 15:36:09 2007
@@ -427,22 +427,18 @@
BitSet fields = null;
FieldMetaData[] fmds = _meta.getFields();
- Set fgs = null;
boolean load;
-
for (int i = 0; i < fmds.length; i++) {
- if (exclude != null && exclude.get(i))
- continue;
+ if (_loaded.get(i) || (exclude != null && exclude.get(i)))
+ continue;
switch (mode) {
case LOAD_SERIALIZE:
load = !fmds[i].isTransient();
break;
- case LOAD_FGS:
- load = false;
- if (fgs == null)
- fgs = new HashSet(fmds.length);
- fgs.add(fmds[i]);
+ case LOAD_FGS:
+ load = fetch == null || fetch.requiresFetch(fmds[i])
+ != FetchConfiguration.FETCH_NONE;
break;
default: // LOAD_ALL
load = true;
@@ -453,22 +449,6 @@
fields = new BitSet(fmds.length);
fields.set(i);
}
- // post process for the fetchGroup: if there is a
- // fetchgroup field, then go to the FetchConfiguration
- // to get the required fetch fields.
- if (fgs != null && fetch != null){
- if (fields == null)
- fields = new BitSet(fmds.length);
- BitSet fgFields = fetch.requiresFetch(fgs, fmds);
- // merge the fetchgroup required fields to the original
- // fields only the fields are not already loaded and
- // are not in the original fields.
- for (int j = 0; j < fgFields.length(); j++) {
- if (fgFields.get(j) && !fields.get(j) && !_loaded.get(j))
- fields.set(j);
- }
- }
-
}
return fields;
}