mirror of https://github.com/apache/openjpa.git
OPENJPA-703: Reinstate performance optimization for DEFAULT and ALL fetch group lookup that was inadvertently rolled back.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@747909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
094f914969
commit
b0a4367dd0
|
@ -83,6 +83,8 @@ public class FetchConfigurationImpl
|
|||
public Set rootClasses;
|
||||
public Set rootInstances;
|
||||
public Map hints = null;
|
||||
public boolean fetchGroupContainsDefault = false;
|
||||
public boolean fetchGroupContainsAll = false;
|
||||
}
|
||||
|
||||
private final ConfigurationState _state;
|
||||
|
@ -241,6 +243,16 @@ public class FetchConfigurationImpl
|
|||
|| _state.fetchGroups.contains(FetchGroup.NAME_ALL));
|
||||
}
|
||||
|
||||
public boolean hasFetchGroupDefault() {
|
||||
// Fetch group All includes fetch group Default by definition
|
||||
return _state.fetchGroupContainsDefault ||
|
||||
_state.fetchGroupContainsAll;
|
||||
}
|
||||
|
||||
public boolean hasFetchGroupAll() {
|
||||
return _state.fetchGroupContainsAll;
|
||||
}
|
||||
|
||||
public FetchConfiguration addFetchGroup(String name) {
|
||||
if (StringUtils.isEmpty(name))
|
||||
throw new UserException(_loc.get("null-fg"));
|
||||
|
@ -250,6 +262,10 @@ public class FetchConfigurationImpl
|
|||
if (_state.fetchGroups == null)
|
||||
_state.fetchGroups = new HashSet();
|
||||
_state.fetchGroups.add(name);
|
||||
if (FetchGroup.NAME_ALL.equals(name))
|
||||
_state.fetchGroupContainsAll = true;
|
||||
else if (FetchGroup.NAME_DEFAULT.equals(name))
|
||||
_state.fetchGroupContainsDefault = true;
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
|
@ -267,8 +283,13 @@ public class FetchConfigurationImpl
|
|||
public FetchConfiguration removeFetchGroup(String group) {
|
||||
lock();
|
||||
try {
|
||||
if (_state.fetchGroups != null)
|
||||
if (_state.fetchGroups != null) {
|
||||
_state.fetchGroups.remove(group);
|
||||
if (FetchGroup.NAME_ALL.equals(group))
|
||||
_state.fetchGroupContainsAll = false;
|
||||
else if (FetchGroup.NAME_DEFAULT.equals(group))
|
||||
_state.fetchGroupContainsDefault = false;
|
||||
}
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
|
@ -278,8 +299,9 @@ public class FetchConfigurationImpl
|
|||
public FetchConfiguration removeFetchGroups(Collection groups) {
|
||||
lock();
|
||||
try {
|
||||
if (_state.fetchGroups != null)
|
||||
_state.fetchGroups.removeAll(groups);
|
||||
if (_state.fetchGroups != null && groups != null)
|
||||
for (Object group : groups)
|
||||
removeFetchGroup(group.toString());
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
|
@ -289,8 +311,11 @@ public class FetchConfigurationImpl
|
|||
public FetchConfiguration clearFetchGroups() {
|
||||
lock();
|
||||
try {
|
||||
if (_state.fetchGroups != null)
|
||||
if (_state.fetchGroups != null) {
|
||||
_state.fetchGroups.clear();
|
||||
_state.fetchGroupContainsAll = false;
|
||||
_state.fetchGroupContainsDefault = true;
|
||||
}
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
|
@ -588,13 +613,11 @@ public class FetchConfigurationImpl
|
|||
* Whether our configuration state includes the given field.
|
||||
*/
|
||||
private boolean includes(FieldMetaData fmd) {
|
||||
if ((fmd.isInDefaultFetchGroup()
|
||||
&& hasFetchGroup(FetchGroup.NAME_DEFAULT))
|
||||
|| hasFetchGroup(FetchGroup.NAME_ALL)
|
||||
|| hasField(fmd.getFullName(false))
|
||||
|| hasField(fmd.getRealName()) // OPENJPA-704
|
||||
|| (_fromField != null
|
||||
&& hasField(_fromField + "." + fmd.getName())))
|
||||
if (hasFetchGroupAll()
|
||||
|| (hasFetchGroupDefault() && fmd.isInDefaultFetchGroup())
|
||||
|| hasField(fmd.getFullName(false))
|
||||
|| hasField(fmd.getRealName())
|
||||
|| (_fromField != null && hasField(_fromField + "." + fmd.getName())))
|
||||
return true;
|
||||
String[] fgs = fmd.getCustomFetchGroups();
|
||||
for (int i = 0; i < fgs.length; i++)
|
||||
|
|
Loading…
Reference in New Issue