Change default MaxFetchDepth to -1 (unlimited). Also move the use of multiple

configuration prefixes to ProductDerivations for simple static access.  Modify
some cases of looking for "openjpa." prefixes to properties to properly look 
for all configured prefixes instead.



git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@450114 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2006-09-26 16:54:30 +00:00
parent d3956a7d98
commit 62bc6c997c
25 changed files with 182 additions and 143 deletions

View File

@ -241,7 +241,6 @@ public interface JDBCConfiguration
* <li><code>parallel</code>: When querying for objects, also select for
* both 1-1 relations using joins and to-many relations using batched
* selects.</li>
* </li>
* </ul>
*/
public void setEagerFetchMode(String mode);

View File

@ -865,9 +865,15 @@ public class JDBCConfigurationImpl
}
protected boolean isInvalidProperty(String propName) {
if (super.isInvalidProperty(propName))
return true;
// handle openjpa.jdbc.SomeMisspelledProperty, but not
// openjpa.someotherimplementation.SomeProperty
return super.isInvalidProperty(propName)
|| propName.toLowerCase().startsWith("openjpa.jdbc");
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
for (int i = 0; i < prefixes.length; i++)
if (propName.toLowerCase().startsWith(prefixes[i] + ".jdbc"))
return true;
return false;
}
}

View File

@ -39,8 +39,7 @@ public class JDBCProductDerivation extends AbstractProductDerivation
public boolean beforeConfigurationConstruct(ConfigurationProvider cp) {
// default to JDBC when no broker factory set
if (BrokerFactoryValue.get(cp) == null) {
cp.addProperty(BrokerFactoryValue.getKey(cp),
JDBCBrokerFactory.class.getName());
BrokerFactoryValue.set(cp, JDBCBrokerFactory.class.getName());
return true;
}
return false;

View File

@ -930,7 +930,7 @@ public class MappingTool
flags.dropTables = opts.removeBooleanProperty
("dropTables", "dt", flags.dropTables);
flags.openjpaTables = opts.removeBooleanProperty
("openjpaTables", "kt", flags.openjpaTables);
("openjpaTables", "ot", flags.openjpaTables);
flags.dropSequences = opts.removeBooleanProperty
("dropSequences", "dsq", flags.dropSequences);
flags.readSchema = opts.removeBooleanProperty

View File

@ -1376,7 +1376,7 @@ public class SchemaTool {
flags.ignoreErrors = opts.removeBooleanProperty
("ignoreErrors", "i", flags.ignoreErrors);
flags.openjpaTables = opts.removeBooleanProperty
("openjpaTables", "kt", flags.openjpaTables);
("openjpaTables", "ot", flags.openjpaTables);
flags.primaryKeys = opts.removeBooleanProperty
("primaryKeys", "pk", flags.primaryKeys);
flags.foreignKeys = opts.removeBooleanProperty

View File

@ -80,7 +80,7 @@ public class OracleDictionary
public String autoAssignSequenceName = null;
/**
* Flag to use OpenJPA 3 style naming for auto assign sequence name and
* Flag to use OpenJPA 0.3 style naming for auto assign sequence name and
* trigger name for backwards compatibility.
*/
public boolean openjpa3GeneratedKeyNames = false;

View File

@ -264,7 +264,7 @@ tool-usage: Usage: java org.apache.openjpa.jdbc.meta.MappingTool\n\
\t[-foreignKeys/-fk <true/t | false/f>]\n\
\t[-indexes/-ix <true/t | false/f>]\n\
\t[-dropTables/-dt <true/t | false/f>]\n\
\t[-openjpaTables/-kt <true/t | false/f>]\n\
\t[-openjpaTables/-ot <true/t | false/f>]\n\
\t[-dropSequences/-dsq <true/t | false/f>]\n\
\t[-sequences/-sq <true/t | false/f>]\n\
\t[-ignoreErrors/-i <true/t | false/f>]\n\

View File

@ -54,7 +54,7 @@ tool-usage: Usage: java org.apache.openjpa.jdbc.schema.SchemaTool\n\
\t[-file/-f <stdout | output file or resource>]\n\
\t[-ignoreErrors/-i <true/t | false/f>]\n\
\t[-dropTables/-dt <true/t | false/f>]\n\
\t[-openjpaTables/-kt <true/t | false/f>]\n\
\t[-openjpaTables/-ot <true/t | false/f>]\n\
\t[-dropSequences/-dsq <true/t | false/f>]\n\
\t[-sequences/-sq <true/t | false/f>]\n\
\t[-primaryKeys/-pk <true/t | false/f>]\n\

View File

@ -23,6 +23,7 @@ import org.apache.openjpa.abstractstore.AbstractStoreBrokerFactory;
import org.apache.openjpa.kernel.BrokerFactory;
import org.apache.openjpa.lib.conf.ConfigurationProvider;
import org.apache.openjpa.lib.conf.PluginValue;
import org.apache.openjpa.lib.conf.ProductDerivations;
/**
* Value type used to represent the {@link BrokerFactory}. This type is
@ -40,20 +41,10 @@ public class BrokerFactoryValue
private static final List _aliases = new ArrayList();
private static final List _prefixes = new ArrayList(2);
static {
_prefixes.add("openjpa");
addDefaultAlias("abstractstore",
AbstractStoreBrokerFactory.class.getName());
}
/**
* Add <code>prefix</code> to the list of prefixes under which configuration
* properties may be scoped.
*/
public static void addPropertyPrefix(String prefix) {
if (!_prefixes.contains(prefix))
_prefixes.add(prefix);
}
/**
* Add a mapping from <code>alias</code> to <code>cls</code> to the list
* of default aliases for new values created after this invocation.
@ -67,10 +58,11 @@ public class BrokerFactoryValue
* Extract the value of this property if set in the given provider.
*/
public static Object get(ConfigurationProvider cp) {
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
Map props = cp.getProperties();
Object bf;
for (int i = 0; i < _prefixes.size (); i++) {
bf = props.get(_prefixes.get(i) + "." + KEY);
for (int i = 0; i < prefixes.length; i++) {
bf = props.get(prefixes[i] + "." + KEY);
if (bf != null)
return bf;
}
@ -78,10 +70,10 @@ public class BrokerFactoryValue
}
/**
* Return the key to use for this property.
* Set the value of this property in the given provider.
*/
public static String getKey(ConfigurationProvider cp) {
return _prefixes.get(0) + "." + KEY;
public static void set(ConfigurationProvider cp, String value) {
cp.addProperty("openjpa." + KEY, value);
}
public BrokerFactoryValue() {

View File

@ -165,14 +165,6 @@ public class OpenJPAConfigurationImpl
super(false);
String[] aliases;
// setup super's log factory plugin
logFactoryPlugin.setProperty("Log");
logFactoryPlugin.setAlias("openjpa",
"org.apache.openjpa.lib.log.LogFactoryImpl");
aliases = logFactoryPlugin.getAliases();
logFactoryPlugin.setDefault(aliases[0]);
logFactoryPlugin.setString(aliases[0]);
classResolverPlugin = addPlugin("ClassResolver", true);
aliases = new String[]{
"default", "org.apache.openjpa.util.ClassResolverImpl",
@ -401,8 +393,8 @@ public class OpenJPAConfigurationImpl
fetchBatchSize.set(-1);
maxFetchDepth = addInt("MaxFetchDepth");
maxFetchDepth.setDefault("1");
maxFetchDepth.set(1);
maxFetchDepth.setDefault("-1");
maxFetchDepth.set(-1);
fetchGroups = addStringList("FetchGroups");
fetchGroups.setDefault("default");

View File

@ -3399,8 +3399,8 @@ public class BrokerImpl
default:
// use store manager for native sequence
if (fmd == null) {
// this will return a sequence even for app id classes, which
// is what we want for backwards-compatibility
// this will return a sequence even for app id classes,
// which is what we want for backwards-compatibility
return _store.getDataStoreIdSequence(meta);
}
return _store.getValueSequence(fmd);

View File

@ -297,8 +297,7 @@ public class QueryImpl
_extent = _broker.newExtent(cls, _subclasses);
_extent.setIgnoreChanges(_ignoreChanges);
} else if (_extent != null
&& _extent.getIgnoreChanges() != _ignoreChanges && cls != null)
{
&& _extent.getIgnoreChanges() != _ignoreChanges && cls != null){
_extent = _broker.newExtent(cls, _extent.hasSubclasses());
_extent.setIgnoreChanges(_ignoreChanges);
}

View File

@ -27,6 +27,10 @@ import java.util.Map;
public abstract class AbstractProductDerivation
implements ProductDerivation {
public String getConfigurationPrefix() {
return null;
}
public ConfigurationProvider loadGlobals(ClassLoader loader)
throws Exception {
return null;

View File

@ -78,8 +78,7 @@ public interface Configuration
public String getProductName();
/**
* Set the product name. The set name will automatically be added to
* the property prefixes.
* Set the product name.
*/
public void setProductName(String name);
@ -160,14 +159,6 @@ public interface Configuration
*/
public void fromProperties(Map map);
/**
* Add <code>prefix</code> to the list of prefixes to use
* to identify valid configuration properties. "openjpa" and any
* product name set with {@link #setProductName} will automatically
* be added.
*/
public void addPropertyPrefix(String prefix);
/**
* Adds a listener for any property changes. The property events fired
* will <b>not</b> include the old value.

View File

@ -108,7 +108,6 @@ public class ConfigurationImpl
private boolean _globals = false;
private String _auto = null;
private final List _vals = new ArrayList();
private List _prefixes = new ArrayList(2);
// property listener helper
private PropertyChangeSupport _changeSupport = null;
@ -131,11 +130,12 @@ public class ConfigurationImpl
* @param loadGlobals whether to attempt to load the global properties
*/
public ConfigurationImpl(boolean loadGlobals) {
setProductName("openjpa"); // also adds as prop prefix
setProductName("openjpa");
logFactoryPlugin = addPlugin("Log", true);
String[] aliases = new String[]{
"true", LogFactoryImpl.class.getName(),
"openjpa", LogFactoryImpl.class.getName(),
"commons", "org.apache.openjpa.lib.log.CommonsLogFactory",
"log4j", "org.apache.openjpa.lib.log.Log4JLogFactory",
"none", NoneLogFactory.class.getName(),
@ -183,7 +183,6 @@ public class ConfigurationImpl
public void setProductName(String name) {
_product = name;
addPropertyPrefix(name);
}
public LogFactory getLogFactory() {
@ -307,8 +306,8 @@ public class ConfigurationImpl
// keep cached props up to date
if (_props != null) {
if (newString == null)
remove(_props, val);
else if (containsKey(_props, val)
Configurations.removeProperty(val.getProperty(), _props);
else if (Configurations.containsProperty(val.getProperty(), _props)
|| val.getDefault() == null
|| !val.getDefault().equals(newString))
put(_props, val, newString);
@ -534,11 +533,6 @@ public class ConfigurationImpl
// To/from maps
////////////////
public void addPropertyPrefix(String prefix) {
if (!_prefixes.contains(prefix))
_prefixes.add(prefix);
}
public Map toProperties(boolean storeDefaults) {
// clone properties before making any modifications; we need to keep
// the internal properties instance consistent to maintain equals and
@ -560,7 +554,8 @@ public class ConfigurationImpl
// if key in existing properties, we already know value is up
// to date
val = (Value) _vals.get(i);
if (_props != null && containsKey(_props, val))
if (_props != null && Configurations.containsProperty
(val.getProperty(), _props))
continue;
str = val.getString();
@ -605,14 +600,13 @@ public class ConfigurationImpl
ser &= o instanceof Serializable;
val.setObject(o);
}
remove(remaining, val);
Configurations.removeProperty(val.getProperty(), remaining);
}
// convention is to point product at a resource with the
// <prefix>.properties System property; remove that property so we
// we don't warn about it
for (int i = 0; i < _prefixes.size(); i++)
remaining.remove(_prefixes.get(i) + ".properties");
Configurations.removeProperty("properties", remaining);
// now warn if there are any remaining properties that there
// is an unhandled prop
@ -637,39 +631,20 @@ public class ConfigurationImpl
private void put(Map map, Value val, Object o) {
Object key = val.getLoadKey();
if (key == null)
key = _prefixes.get(0) + "." + val.getProperty();
key = "openjpa." + val.getProperty();
map.put(key, o);
}
/**
* Return whether <code>map</code> contains an entry for <code>val</code>.
*/
private boolean containsKey(Map map, Value val) {
for (int i = 0; i < _prefixes.size(); i++)
if (map.containsKey(_prefixes.get(i) + "." + val.getProperty()))
return true;
return false;
}
/**
* Removes <code>val</code> from <code>map</code>. Use this method
* instead of attempting to remove the value directly because this will
* account for any duplicate-but-same-valued keys in the map.
*/
private void remove(Map map, Value val) {
for (int i = 0; i < _prefixes.size(); i++)
map.remove(_prefixes.get(i) + "." + val.getProperty());
}
/**
* Look up the given value, testing all available prefixes.
*/
private Object get(Map map, Value val, boolean setLoadKey) {
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
String firstKey = null;
String key;
Object o = null;
for (int i = 0; i < _prefixes.size(); i++) {
key = _prefixes.get(i) + "." + val.getProperty();
for (int i = 0; i < prefixes.length; i++) {
key = prefixes[i] + "." + val.getProperty();
if (firstKey == null) {
o = map.get(key);
if (o != null)
@ -712,11 +687,11 @@ public class ConfigurationImpl
* Return a comprehensive list of recognized map keys.
*/
private Collection newPropertyList() {
List l = new ArrayList(_vals.size() * _prefixes.size());
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
List l = new ArrayList(_vals.size() * prefixes.length);
for (int i = 0; i < _vals.size(); i++) {
for (int j = 0; j < _prefixes.size(); j++)
l.add(_prefixes.get(j) + "."
+ ((Value) _vals.get(i)).getProperty());
for (int j = 0; j < prefixes.length; j++)
l.add(prefixes[j] + "." + ((Value) _vals.get(i)).getProperty());
}
return l;
}
@ -729,12 +704,11 @@ public class ConfigurationImpl
// handle warnings for openjpa.SomeString, but not for
// openjpa.some.subpackage.SomeString, since it might be valid for some
// specific implementation of OpenJPA
String prefix;
for (int i = 0; i < _prefixes.size(); i++) {
prefix = (String) _prefixes.get(i) + ".";
if (propName.toLowerCase().startsWith(prefix)
&& propName.length() > prefix.length()
&& propName.indexOf('.', prefix.length()) == -1)
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
for (int i = 0; i < prefixes.length; i++) {
if (propName.toLowerCase().startsWith(prefixes[i])
&& propName.length() > prefixes[i].length()
&& propName.indexOf('.', prefixes[i].length()) == -1)
return true;
}
return false;
@ -861,7 +835,6 @@ public class ConfigurationImpl
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
fromProperties((Map) in.readObject());
_prefixes = (List) in.readObject();
_globals = in.readBoolean();
}
@ -874,7 +847,6 @@ public class ConfigurationImpl
out.writeObject(_props);
else
out.writeObject(toProperties(false));
out.writeObject(_prefixes);
out.writeBoolean(_globals);
}
@ -888,8 +860,6 @@ public class ConfigurationImpl
(new Class[]{ boolean.class });
ConfigurationImpl clone = (ConfigurationImpl) cons.newInstance
(new Object[]{ Boolean.FALSE });
clone._prefixes.clear();
clone._prefixes.addAll(_prefixes);
clone._globals = _globals;
clone.fromProperties(toProperties(true));
return clone;

View File

@ -468,4 +468,53 @@ public class Configurations {
try { ctx.close(); } catch (Exception e) {}
}
}
/**
* Test whether the map contains the given key, prefixed with any possible
* configuration prefix.
*/
public static boolean containsProperty(String key, Map props) {
if (key == null || props == null)
return false;
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
for (int i = 0; i < prefixes.length; i++)
if (props.containsKey(prefixes[i] + "." + key))
return true;
return false;
}
/**
* Get the property under the given key, prefixed with any possible
* configuration prefix.
*/
public static Object getProperty(String key, Map props) {
if (key == null || props == null)
return null;
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
Object val;
for (int i = 0; i < prefixes.length; i++) {
val = props.get(prefixes[i] + "." + key);
if (val != null)
return val;
}
return null;
}
/**
* Remove the property under the given key, prefixed with any possible
* configuration prefix.
*/
public static Object removeProperty(String key, Map props) {
if (key == null || props == null)
return null;
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
Object val = null;
Object cur;
for (int i = 0; i < prefixes.length; i++) {
cur = props.remove(prefixes[i] + "." + key);
if (cur != null && val == null)
val = cur;
}
return val;
}
}

View File

@ -40,6 +40,11 @@ public interface ProductDerivation {
*/
public int getType();
/**
* Return the configuration prefix for properties of this product.
*/
public String getConfigurationPrefix();
/**
* Load globals into the returned ConfigurationProvider, or return null if
* no globals is found.

View File

@ -34,6 +34,7 @@ import org.apache.openjpa.lib.util.Services;
public class ProductDerivations {
private static final ProductDerivation[] _derivations;
private static final String[] _prefixes;
static {
Class[] pdcls = Services.getImplementorClasses(ProductDerivation.class,
ProductDerivation.class.getClassLoader());
@ -59,6 +60,24 @@ public class ProductDerivations {
Collections.sort(derivations, new ProductDerivationComparator());
_derivations = (ProductDerivation[]) derivations.toArray
(new ProductDerivation[derivations.size()]);
List prefixes = new ArrayList(2);
for (int i = 0; i < _derivations.length; i++) {
if (_derivations[i].getConfigurationPrefix() != null
&& !"openjpa".equals(_derivations[i].getConfigurationPrefix()))
prefixes.add(_derivations[i].getConfigurationPrefix());
}
_prefixes = new String[1 + prefixes.size()];
_prefixes[0] = "openjpa";
for (int i = 0; i < prefixes.size(); i++)
_prefixes[i + 1] = (String) prefixes.get(i);
}
/**
* Return the recognized prefixes for configuration properties.
*/
public static String[] getConfigurationPrefixes() {
return _prefixes;
}
/**

View File

@ -69,8 +69,8 @@ public class TestPersistence
// openjpa-facade test
assertTrue(em instanceof OpenJPAEntityManager);
OpenJPAEntityManager ojem = (OpenJPAEntityManager) em;
ojem.getFetchPlan().setMaxFetchDepth(-1);
assertEquals(-1, ojem.getFetchPlan().getMaxFetchDepth());
ojem.getFetchPlan().setMaxFetchDepth(1);
assertEquals(1, ojem.getFetchPlan().getMaxFetchDepth());
em.close();
}

View File

@ -34,6 +34,8 @@ import org.apache.openjpa.kernel.BrokerFactory;
import org.apache.openjpa.kernel.DelegatingBrokerFactory;
import org.apache.openjpa.kernel.DelegatingFetchConfiguration;
import org.apache.openjpa.kernel.FetchConfiguration;
import org.apache.openjpa.lib.conf.Configurations;
import org.apache.openjpa.lib.conf.ProductDerivations;
import org.apache.openjpa.lib.conf.Value;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.util.ImplHelper;
@ -145,42 +147,42 @@ public class EntityManagerFactoryImpl
props = new HashMap(props);
OpenJPAConfiguration conf = getConfiguration();
String user =
(String) props.remove("openjpa.ConnectionUserName");
String user = (String) Configurations.removeProperty
("ConnectionUserName", props);
if (user == null)
user = conf.getConnectionUserName();
String pass =
(String) props.remove("openjpa.ConnectionPassword");
String pass = (String) Configurations.removeProperty
("ConnectionPassword", props);
if (pass == null)
pass = conf.getConnectionPassword();
String str =
(String) props.remove("openjpa.TransactionMode");
String str = (String) Configurations.removeProperty
("TransactionMode", props);
boolean managed;
if (str == null)
managed = conf.isTransactionModeManaged();
else {
Value val = conf.getValue("openjpa.TransactionMode");
Value val = conf.getValue("TransactionMode");
managed = Boolean.parseBoolean(val.unalias(str));
}
Object obj = props.remove("openjpa.ConnectionRetainMode");
Object obj = Configurations.removeProperty("ConnectionRetainMode",
props);
int retainMode;
if (obj instanceof Number)
retainMode = ((Number) obj).intValue();
else if (obj != null) {
Value val =
conf.getValue("openjpa.ConnectionRetainMode");
else if (obj == null)
retainMode = conf.getConnectionRetainModeConstant();
else {
Value val = conf.getValue("ConnectionRetainMode");
try {
retainMode = Integer.parseInt(val.unalias((String) obj));
} catch (Exception e) {
throw new ArgumentException(_loc.get("bad-em-prop",
"openjpa.ConnectionRetainMode", obj),
new Throwable[]{ e },
obj, true);
new Throwable[]{ e }, obj, true);
}
} else
retainMode = conf.getConnectionRetainModeConstant();
}
Broker broker = _factory.newBroker(user, pass, managed, retainMode,
false);
@ -191,15 +193,23 @@ public class EntityManagerFactoryImpl
OpenJPAEntityManager em = newEntityManagerImpl(broker);
// allow setting of other bean properties of EM
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
List<RuntimeException> errs = null;
Method setter = null;
String prop;
String prop, prefix;
Object val;
for (Map.Entry entry : (Set<Map.Entry>) props.entrySet()) {
prop = (String) entry.getKey();
if (!prop.startsWith("openjpa."))
prefix = null;
for (int i = 0; i < prefixes.length; i++) {
prefix = prefixes[i] + ".";
if (prop.startsWith(prefix))
break;
prefix = null;
}
if (prefix == null)
continue;
prop = prop.substring("openjpa.".length());
prop = prop.substring(prefix.length());
try {
setter = ImplHelper.getSetter(em.getClass(), prop);
} catch (OpenJPAException ke) {

View File

@ -32,6 +32,7 @@ import org.apache.openjpa.conf.OpenJPAConfiguration;
import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
import org.apache.openjpa.conf.OpenJPAProductDerivation;
import org.apache.openjpa.lib.conf.AbstractProductDerivation;
import org.apache.openjpa.lib.conf.ProductDerivations;
import org.apache.openjpa.lib.conf.Configuration;
import org.apache.openjpa.lib.conf.ConfigurationProvider;
import org.apache.openjpa.lib.conf.MapConfigurationProvider;
@ -180,7 +181,10 @@ public class PersistenceProductDerivation
@Override
public ConfigurationProvider loadGlobals(ClassLoader loader)
throws IOException {
String rsrc = System.getProperty("openjpa.properties");
String[] prefixes = ProductDerivations.getConfigurationPrefixes();
String rsrc = null;
for (int i = 0; i < prefixes.length && StringUtils.isEmpty(rsrc); i++)
rsrc = System.getProperty(prefixes[i] + ".properties");
boolean explicit = !StringUtils.isEmpty(rsrc);
String anchor = null;
int idx = (!explicit) ? -1 : rsrc.lastIndexOf('#');

View File

@ -50,8 +50,7 @@ import org.apache.openjpa.meta.MetaDataRepository;
public class PersistenceProviderImpl
implements PersistenceProvider {
static final String CLASS_TRANSFORMER_OPTIONS =
"openjpa.ClassTransformerOptions";
static final String CLASS_TRANSFORMER_OPTIONS = "ClassTransformerOptions";
/**
* Loads the entity manager specified by <code>name</code>, applying
@ -71,8 +70,6 @@ public class PersistenceProviderImpl
if (cp == null)
return null;
if (m != null)
cp.addProperties(m);
BrokerFactory factory = Bootstrap.newBrokerFactory(cp, null);
return OpenJPAPersistence.toEntityManagerFactory(factory);
} catch (Exception e) {
@ -97,9 +94,8 @@ public class PersistenceProviderImpl
OpenJPAEntityManagerFactory emf =
OpenJPAPersistence.toEntityManagerFactory(factory);
Properties p = pui.getProperties();
String ctOpts = null;
if (p != null)
ctOpts = p.getProperty(CLASS_TRANSFORMER_OPTIONS);
String ctOpts = (String) Configurations.getProperty
(CLASS_TRANSFORMER_OPTIONS, p);
pui.addTransformer(new ClassTransformerImpl(emf.getConfiguration(),
ctOpts, pui.getNewTempClassLoader()));
return emf;

View File

@ -403,7 +403,8 @@ public class PersistenceUnitInfoImpl
}
if (!metaFactoryProps.isEmpty()) {
// set persistent class locations as properties of metadata factory
String factory = (String) map.get("openjpa.MetaDataFactory");
String factory = (String) Configurations.getProperty
("MetaDataFactory", map);
if (factory == null)
factory = Configurations.serializeProperties(metaFactoryProps);
else {
@ -417,7 +418,8 @@ public class PersistenceUnitInfoImpl
}
// always record provider name for product derivations to access
map.put(KEY_PROVIDER, info.getPersistenceProviderClassName());
if (info.getPersistenceProviderClassName() != null)
map.put(KEY_PROVIDER, info.getPersistenceProviderClassName());
return map;
}

View File

@ -2120,11 +2120,11 @@ object-to-datastore mapping to use.
MaxFetchDepth</literal>
</para>
<para>
<emphasis role="bold">Default:</emphasis><literal>1</literal>
<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. See
traverse when eager fetching. Use -1 for no limit. Defaults to no limit. See
<xref linkend="ref_guide_perfpack_eager"/> for details on eager fetching.
</para>
</section>

View File

@ -1828,15 +1828,17 @@ fetch group names.
You can also set the system's default maximum fetch depth with the
<link linkend="openjpa.MaxFetchDepth"><literal>openjpa.MaxFetchDepth</literal>
</link> configuration property. The maximum fetch depth determines how "deep"
into the object graph to traverse when loading an instance. The default maximum
depth is 1, meaning that OpenJPA will load at most the target instance and its
immediate relations. By increasing the depth, you can allow OpenJPA to also
load relations of relations, to arbitrary depth. A value of -1 symbolizes an
infinite maximum, telling OpenJPA to fetch configured relations until it reaches
the edges of the object graph. Of course, which relation fields are loaded
depends on whether the fields are eager or lazy, and on the active fetch groups.
A fetch group member's recursion depth may also limit the fetch depth to
something less than the configured maximum.
into the object graph to traverse when loading an instance. For example, with
a <literal>MaxFetchDepth</literal> of 1, OpenJPA will load at most the target
instance and its immediate relations. With a <literal>MaxFetchDepth</literal>
of 2, OpenJPA may load the target instance, its immediate relations, and
the relations of those relations. This works to arbitrary depth. In fact,
the default <literal>MaxFetchDepth</literal> value is -1, which symbolizes
infinite depth. Under this setting, OpenJPA will fetch configured relations
until it reaches the edges of the object graph. Of course, which relation
fields are loaded depends on whether the fields are eager or lazy, and on the
active fetch groups. A fetch group member's recursion depth may also limit
the fetch depth to something less than the configured maximum.
</para>
<para>
OpenJPA's <classname>OpenJPAEntityManager</classname> and <classname>