openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r522623 - in /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: kernel/QueryFlushModes.java meta/ClassMetaData.java meta/MetaDataRepository.java
Date Mon, 26 Mar 2007 20:52:15 GMT
Author: awhite
Date: Mon Mar 26 13:52:14 2007
New Revision: 522623

URL: http://svn.apache.org/viewvc?view=rev&rev=522623
Log:
Only process registered classes that are listed as belonging to this persistence
unit.  


Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryFlushModes.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryFlushModes.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryFlushModes.java?view=diff&rev=522623&r1=522622&r2=522623
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryFlushModes.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryFlushModes.java
Mon Mar 26 13:52:14 2007
@@ -29,7 +29,8 @@
      * Constant denoting that queries should flush data to the
      * database automatically whenever OpenJPA determines that relevant
      * modifications have been made and IgnoreCache is
-     * <code>false</code>. See {@link OpenJPAConfiguration#getFlushBeforeQueries}
+     * <code>false</code>. See 
+     * {@link OpenJPAConfiguration#getFlushBeforeQueries}
      * for more info.
      */
     public static final int FLUSH_TRUE = 0;

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?view=diff&rev=522623&r1=522622&r2=522623
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Mon Mar 26 13:52:14 2007
@@ -310,7 +310,7 @@
         if (_owner != null)
             return _repos.EMPTY_CLASSES;
 
-        _repos.processRegisteredClasses();
+        _repos.processRegisteredClasses(_loader);
         if (_subs == null) {
             Collection subs = _repos.getPCSubclasses(_type);
             _subs = (Class[]) subs.toArray(new Class[subs.size()]);

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?view=diff&rev=522623&r1=522622&r2=522623
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Mon Mar 26 13:52:14 2007
@@ -304,7 +304,7 @@
             return null;
 
         // check cache
-        processRegisteredClasses();
+        processRegisteredClasses(envLoader);
         List classList = (List) _aliases.get(alias);
 
         // multiple classes may have been defined with the same alias: we
@@ -322,8 +322,8 @@
 
                 // if we have specified a list of persistent clases,
                 // also check to ensure that the class is in that list
-                if (pcNames == null || pcNames.size() == 0 ||
-                    pcNames.contains(nc.getName())) {
+                if (pcNames == null || pcNames.size() == 0 
+                    || pcNames.contains(nc.getName())) {
                     cls = nc;
                     if (!classList.contains(cls))
                         classList.add(cls);
@@ -375,7 +375,7 @@
         // dev time so that user can manipulate persistent classes he's writing
         // before adding them to the list
         if ((_validate & VALIDATE_RUNTIME) != 0) {
-            Set pcNames = _factory.getPersistentTypeNames(false, envLoader);
+            Set pcNames = getPersistentTypeNames(false, envLoader);
             if (pcNames != null && !pcNames.contains(cls.getName()))
                 return meta;
         }
@@ -930,7 +930,7 @@
         }
 
         // check cache
-        processRegisteredClasses();
+        processRegisteredClasses(envLoader);
         Class cls = (Class) _oids.get(oid.getClass());
         if (cls != null)
             return getMetaData(cls, envLoader, mustExist);
@@ -946,7 +946,7 @@
         // if still not match, register any classes that look similar to the
         // oid class and check again
         resolveIdentityClass(oid);
-        if (processRegisteredClasses().length > 0) {
+        if (processRegisteredClasses(envLoader).length > 0) {
             cls = (Class) _oids.get(oid.getClass());
             if (cls != null)
                 return getMetaData(cls, envLoader, mustExist);
@@ -1201,7 +1201,7 @@
      */
     public synchronized Collection loadPersistentTypes(boolean devpath,
         ClassLoader envLoader) {
-        Set names = _factory.getPersistentTypeNames(devpath, envLoader);
+        Set names = getPersistentTypeNames(devpath, envLoader);
         if (names == null || names.isEmpty())
             return Collections.EMPTY_LIST;
 
@@ -1264,7 +1264,7 @@
      * Parses the metadata for all registered classes.
      */
     private void loadRegisteredClassMetaData(ClassLoader envLoader) {
-        Class[] reg = processRegisteredClasses();
+        Class[] reg = processRegisteredClasses(envLoader);
         for (int i = 0; i < reg.length; i++) {
             try {
                 getMetaData(reg[i], envLoader, false);
@@ -1278,7 +1278,7 @@
     /**
      * Updates our datastructures with the latest registered classes.
      */
-    Class[] processRegisteredClasses() {
+    Class[] processRegisteredClasses(ClassLoader envLoader) {
         if (_registered.isEmpty())
             return EMPTY_CLASSES;
 
@@ -1290,8 +1290,15 @@
             _registered.clear();
         }
 
+        Collection pcNames = getPersistentTypeNames(false, envLoader);
         Collection failed = null;
         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 {
                 processRegisteredClass(reg[i]);
             } catch (Throwable t) {
@@ -1492,7 +1499,7 @@
         if (meta == null && mustExist) {
             if (cls == null) {
                 throw new MetaDataException(_loc.get
-                    ("no-named-query-null-class",
+                    ("no-named-query-null-class", 
                         getPersistentTypeNames(false, envLoader), name));
             } else {
                 throw new MetaDataException(_loc.get("no-named-query",



Mime
View raw message