Added openjpa.MaxFetchDepth configuration property to globally control default

max fetch depth.



git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@427191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2006-07-31 18:24:44 +00:00
parent 979d2340e9
commit f279a6790b
5 changed files with 85 additions and 3 deletions

View File

@ -1023,6 +1023,23 @@ public interface OpenJPAConfiguration
*/
public void setFetchBatchSize(Integer size);
/**
* The maximum relation depth to traverse when eager fetching. Use
* -1 for no limit.
*/
public int getMaxFetchDepth();
/**
* The maximum relation depth to traverse when eager fetching. Use
* -1 for no limit.
*/
public void setMaxFetchDepth(int depth);
/**
* Wrapper for JCA usage of {@link #setMaxFetchDepth(int)}.
*/
public void setMaxFetchDepth(Integer size);
/**
* Comma-separated list of fetch group names that will be pre-set for
* all new {@link FetchConfiguration}s.

View File

@ -91,6 +91,7 @@ public class OpenJPAConfigurationImpl
public BooleanValue transactionMode;
public IntValue connectionRetainMode;
public IntValue fetchBatchSize;
public IntValue maxFetchDepth;
public StringListValue fetchGroups;
public IntValue flushBeforeQueries;
public IntValue lockTimeout;
@ -410,6 +411,10 @@ public class OpenJPAConfigurationImpl
fetchBatchSize.setDefault("-1");
fetchBatchSize.set(-1);
maxFetchDepth = addInt("MaxFetchDepth");
maxFetchDepth.setDefault("1");
maxFetchDepth.set(1);
fetchGroups = addStringList("FetchGroups");
fetchGroups.setDefault("default");
fetchGroups.set(new String[]{ "default" });
@ -1207,6 +1212,20 @@ public class OpenJPAConfigurationImpl
return fetchBatchSize.get();
}
public void setMaxFetchDepth(int maxFetchDepth) {
assertNotReadOnly();
this.maxFetchDepth.set(maxFetchDepth);
}
public void setMaxFetchDepth(Integer maxFetchDepth) {
if (maxFetchDepth != null)
setMaxFetchDepth(maxFetchDepth.intValue());
}
public int getMaxFetchDepth() {
return maxFetchDepth.get();
}
public void setFetchGroups(String fetchGroups) {
assertNotReadOnly();
this.fetchGroups.setString(fetchGroups);

View File

@ -113,6 +113,7 @@ public class FetchConfigurationImpl
setFlushBeforeQueries(conf.getFlushBeforeQueriesConstant());
clearFetchGroups();
addFetchGroups(Arrays.asList(conf.getFetchGroupsList()));
setMaxFetchDepth(conf.getMaxFetchDepth());
}
/**
@ -170,9 +171,14 @@ public class FetchConfigurationImpl
}
public FetchConfiguration setMaxFetchDepth(int depth) {
_state.maxFetchDepth = depth;
if (_parent == null)
_availableDepth = depth;
if (depth == DEFAULT && _state.ctx != null)
depth = _state.ctx.getConfiguration().getMaxFetchDepth();
if (depth != DEFAULT)
{
_state.maxFetchDepth = depth;
if (_parent == null)
_availableDepth = depth;
}
return this;
}

View File

@ -103,6 +103,14 @@ FetchBatchSize-cat: Fetching
FetchBatchSize-displayorder: 50
FetchBatchSize-expert: true
MaxFetchDepth-name: Maximum fetch depth.
MaxFetchDepth-desc: The maximum relation depth to traverse when eager \
fetching, or -1 for no limit.
MaxFetchDepth-type: Optimization
MaxFetchDepth-cat: Fetching
MaxFetchDepth-displayorder: 50
MaxFetchDepth-expert: true
FetchGroups-name: Fetch groups to add to default fetch group
FetchGroups-desc: A comma-separated list of fetch group names that wll be \
loaded by default when fetching data from the data store.

View File

@ -17407,6 +17407,38 @@ true(CacheSize=1000)
</para>
<para><emphasis role="bold">Description:</emphasis> The symbolic name
of the object-to-datastore mapping to use.
</para>
</section>
<section id="openjpa.MaxFetchDepth">
<title>openjpa.MaxFetchDepth</title>
<indexterm zone="openjpa.MaxFetchDepth">
<primary>MaxFetchDepth</primary>
</indexterm>
<indexterm zone="openjpa.MaxFetchDepth">
<primary>eager fetching</primary>
<secondary>MaxFetchDepth</secondary>
</indexterm>
<para>
<emphasis role="bold">Property name:</emphasis>
<literal>openjpa.MaxFetchDepth</literal>
</para>
<para>
<emphasis role="bold">Configuration API:</emphasis>
<ulink url="../apidocs/org/apache/openjpa/conf/OpenJPAConfiguration.html#getMaxFetchDepth">
<methodname>org.apache.openjpa.conf.OpenJPAConfiguration.getMaxFetchDepth</methodname>
</ulink>
</para>
<para>
<emphasis role="bold">Resource adaptor config-property:</emphasis>
<literal>MaxFetchDepth</literal>
</para>
<para>
<emphasis role="bold">Default:</emphasis>
<literal>1</literal>
</para>
<para><emphasis role="bold">Description:</emphasis> The maximum
depth of relations to traverse when eager fetching. Use -1 for no limit.
Defaults to 1.
</para>
</section>
<section id="openjpa.MetaDataFactory">