Only process registered classes that are listed as belonging to this persistence

unit.  



git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@522623 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2007-03-26 20:52:14 +00:00
parent 9b61ded11b
commit df02d831e2
3 changed files with 20 additions and 12 deletions

View File

@ -29,7 +29,8 @@ public interface QueryFlushModes {
* Constant denoting that queries should flush data to the * Constant denoting that queries should flush data to the
* database automatically whenever OpenJPA determines that relevant * database automatically whenever OpenJPA determines that relevant
* modifications have been made and IgnoreCache is * modifications have been made and IgnoreCache is
* <code>false</code>. See {@link OpenJPAConfiguration#getFlushBeforeQueries} * <code>false</code>. See
* {@link OpenJPAConfiguration#getFlushBeforeQueries}
* for more info. * for more info.
*/ */
public static final int FLUSH_TRUE = 0; public static final int FLUSH_TRUE = 0;

View File

@ -310,7 +310,7 @@ public class ClassMetaData
if (_owner != null) if (_owner != null)
return _repos.EMPTY_CLASSES; return _repos.EMPTY_CLASSES;
_repos.processRegisteredClasses(); _repos.processRegisteredClasses(_loader);
if (_subs == null) { if (_subs == null) {
Collection subs = _repos.getPCSubclasses(_type); Collection subs = _repos.getPCSubclasses(_type);
_subs = (Class[]) subs.toArray(new Class[subs.size()]); _subs = (Class[]) subs.toArray(new Class[subs.size()]);

View File

@ -304,7 +304,7 @@ public class MetaDataRepository
return null; return null;
// check cache // check cache
processRegisteredClasses(); processRegisteredClasses(envLoader);
List classList = (List) _aliases.get(alias); List classList = (List) _aliases.get(alias);
// multiple classes may have been defined with the same alias: we // multiple classes may have been defined with the same alias: we
@ -322,8 +322,8 @@ public class MetaDataRepository
// if we have specified a list of persistent clases, // if we have specified a list of persistent clases,
// also check to ensure that the class is in that list // also check to ensure that the class is in that list
if (pcNames == null || pcNames.size() == 0 || if (pcNames == null || pcNames.size() == 0
pcNames.contains(nc.getName())) { || pcNames.contains(nc.getName())) {
cls = nc; cls = nc;
if (!classList.contains(cls)) if (!classList.contains(cls))
classList.add(cls); classList.add(cls);
@ -375,7 +375,7 @@ public class MetaDataRepository
// dev time so that user can manipulate persistent classes he's writing // dev time so that user can manipulate persistent classes he's writing
// before adding them to the list // before adding them to the list
if ((_validate & VALIDATE_RUNTIME) != 0) { if ((_validate & VALIDATE_RUNTIME) != 0) {
Set pcNames = _factory.getPersistentTypeNames(false, envLoader); Set pcNames = getPersistentTypeNames(false, envLoader);
if (pcNames != null && !pcNames.contains(cls.getName())) if (pcNames != null && !pcNames.contains(cls.getName()))
return meta; return meta;
} }
@ -930,7 +930,7 @@ public class MetaDataRepository
} }
// check cache // check cache
processRegisteredClasses(); processRegisteredClasses(envLoader);
Class cls = (Class) _oids.get(oid.getClass()); Class cls = (Class) _oids.get(oid.getClass());
if (cls != null) if (cls != null)
return getMetaData(cls, envLoader, mustExist); return getMetaData(cls, envLoader, mustExist);
@ -946,7 +946,7 @@ public class MetaDataRepository
// if still not match, register any classes that look similar to the // if still not match, register any classes that look similar to the
// oid class and check again // oid class and check again
resolveIdentityClass(oid); resolveIdentityClass(oid);
if (processRegisteredClasses().length > 0) { if (processRegisteredClasses(envLoader).length > 0) {
cls = (Class) _oids.get(oid.getClass()); cls = (Class) _oids.get(oid.getClass());
if (cls != null) if (cls != null)
return getMetaData(cls, envLoader, mustExist); return getMetaData(cls, envLoader, mustExist);
@ -1201,7 +1201,7 @@ public class MetaDataRepository
*/ */
public synchronized Collection loadPersistentTypes(boolean devpath, public synchronized Collection loadPersistentTypes(boolean devpath,
ClassLoader envLoader) { ClassLoader envLoader) {
Set names = _factory.getPersistentTypeNames(devpath, envLoader); Set names = getPersistentTypeNames(devpath, envLoader);
if (names == null || names.isEmpty()) if (names == null || names.isEmpty())
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
@ -1264,7 +1264,7 @@ public class MetaDataRepository
* Parses the metadata for all registered classes. * Parses the metadata for all registered classes.
*/ */
private void loadRegisteredClassMetaData(ClassLoader envLoader) { private void loadRegisteredClassMetaData(ClassLoader envLoader) {
Class[] reg = processRegisteredClasses(); Class[] reg = processRegisteredClasses(envLoader);
for (int i = 0; i < reg.length; i++) { for (int i = 0; i < reg.length; i++) {
try { try {
getMetaData(reg[i], envLoader, false); getMetaData(reg[i], envLoader, false);
@ -1278,7 +1278,7 @@ public class MetaDataRepository
/** /**
* Updates our datastructures with the latest registered classes. * Updates our datastructures with the latest registered classes.
*/ */
Class[] processRegisteredClasses() { Class[] processRegisteredClasses(ClassLoader envLoader) {
if (_registered.isEmpty()) if (_registered.isEmpty())
return EMPTY_CLASSES; return EMPTY_CLASSES;
@ -1290,8 +1290,15 @@ public class MetaDataRepository
_registered.clear(); _registered.clear();
} }
Collection pcNames = getPersistentTypeNames(false, envLoader);
Collection failed = null; Collection failed = null;
for (int i = 0; i < reg.length; i++) { for (int i = 0; i < reg.length; i++) {
// don't process types that aren't listed by the user; may belong
// to a different persistence unit
if (pcNames != null && !pcNames.isEmpty()
&& !pcNames.contains(reg[i].getName()))
continue;
try { try {
processRegisteredClass(reg[i]); processRegisteredClass(reg[i]);
} catch (Throwable t) { } catch (Throwable t) {
@ -1492,7 +1499,7 @@ public class MetaDataRepository
if (meta == null && mustExist) { if (meta == null && mustExist) {
if (cls == null) { if (cls == null) {
throw new MetaDataException(_loc.get throw new MetaDataException(_loc.get
("no-named-query-null-class", ("no-named-query-null-class",
getPersistentTypeNames(false, envLoader), name)); getPersistentTypeNames(false, envLoader), name));
} else { } else {
throw new MetaDataException(_loc.get("no-named-query", throw new MetaDataException(_loc.get("no-named-query",