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 rootClasses;
|
||||||
public Set rootInstances;
|
public Set rootInstances;
|
||||||
public Map hints = null;
|
public Map hints = null;
|
||||||
|
public boolean fetchGroupContainsDefault = false;
|
||||||
|
public boolean fetchGroupContainsAll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ConfigurationState _state;
|
private final ConfigurationState _state;
|
||||||
|
@ -241,6 +243,16 @@ public class FetchConfigurationImpl
|
||||||
|| _state.fetchGroups.contains(FetchGroup.NAME_ALL));
|
|| _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) {
|
public FetchConfiguration addFetchGroup(String name) {
|
||||||
if (StringUtils.isEmpty(name))
|
if (StringUtils.isEmpty(name))
|
||||||
throw new UserException(_loc.get("null-fg"));
|
throw new UserException(_loc.get("null-fg"));
|
||||||
|
@ -250,6 +262,10 @@ public class FetchConfigurationImpl
|
||||||
if (_state.fetchGroups == null)
|
if (_state.fetchGroups == null)
|
||||||
_state.fetchGroups = new HashSet();
|
_state.fetchGroups = new HashSet();
|
||||||
_state.fetchGroups.add(name);
|
_state.fetchGroups.add(name);
|
||||||
|
if (FetchGroup.NAME_ALL.equals(name))
|
||||||
|
_state.fetchGroupContainsAll = true;
|
||||||
|
else if (FetchGroup.NAME_DEFAULT.equals(name))
|
||||||
|
_state.fetchGroupContainsDefault = true;
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@ -267,8 +283,13 @@ public class FetchConfigurationImpl
|
||||||
public FetchConfiguration removeFetchGroup(String group) {
|
public FetchConfiguration removeFetchGroup(String group) {
|
||||||
lock();
|
lock();
|
||||||
try {
|
try {
|
||||||
if (_state.fetchGroups != null)
|
if (_state.fetchGroups != null) {
|
||||||
_state.fetchGroups.remove(group);
|
_state.fetchGroups.remove(group);
|
||||||
|
if (FetchGroup.NAME_ALL.equals(group))
|
||||||
|
_state.fetchGroupContainsAll = false;
|
||||||
|
else if (FetchGroup.NAME_DEFAULT.equals(group))
|
||||||
|
_state.fetchGroupContainsDefault = false;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@ -278,8 +299,9 @@ public class FetchConfigurationImpl
|
||||||
public FetchConfiguration removeFetchGroups(Collection groups) {
|
public FetchConfiguration removeFetchGroups(Collection groups) {
|
||||||
lock();
|
lock();
|
||||||
try {
|
try {
|
||||||
if (_state.fetchGroups != null)
|
if (_state.fetchGroups != null && groups != null)
|
||||||
_state.fetchGroups.removeAll(groups);
|
for (Object group : groups)
|
||||||
|
removeFetchGroup(group.toString());
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@ -289,8 +311,11 @@ public class FetchConfigurationImpl
|
||||||
public FetchConfiguration clearFetchGroups() {
|
public FetchConfiguration clearFetchGroups() {
|
||||||
lock();
|
lock();
|
||||||
try {
|
try {
|
||||||
if (_state.fetchGroups != null)
|
if (_state.fetchGroups != null) {
|
||||||
_state.fetchGroups.clear();
|
_state.fetchGroups.clear();
|
||||||
|
_state.fetchGroupContainsAll = false;
|
||||||
|
_state.fetchGroupContainsDefault = true;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
@ -588,13 +613,11 @@ public class FetchConfigurationImpl
|
||||||
* Whether our configuration state includes the given field.
|
* Whether our configuration state includes the given field.
|
||||||
*/
|
*/
|
||||||
private boolean includes(FieldMetaData fmd) {
|
private boolean includes(FieldMetaData fmd) {
|
||||||
if ((fmd.isInDefaultFetchGroup()
|
if (hasFetchGroupAll()
|
||||||
&& hasFetchGroup(FetchGroup.NAME_DEFAULT))
|
|| (hasFetchGroupDefault() && fmd.isInDefaultFetchGroup())
|
||||||
|| hasFetchGroup(FetchGroup.NAME_ALL)
|
|
||||||
|| hasField(fmd.getFullName(false))
|
|| hasField(fmd.getFullName(false))
|
||||||
|| hasField(fmd.getRealName()) // OPENJPA-704
|
|| hasField(fmd.getRealName())
|
||||||
|| (_fromField != null
|
|| (_fromField != null && hasField(_fromField + "." + fmd.getName())))
|
||||||
&& hasField(_fromField + "." + fmd.getName())))
|
|
||||||
return true;
|
return true;
|
||||||
String[] fgs = fmd.getCustomFetchGroups();
|
String[] fgs = fmd.getCustomFetchGroups();
|
||||||
for (int i = 0; i < fgs.length; i++)
|
for (int i = 0; i < fgs.length; i++)
|
||||||
|
|
Loading…
Reference in New Issue