Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Fix for bug 227046

Guy Pelletier wrote:
Hi Mitesh,
 
The only problem I see now is that the same listener could be added multiple times.
Valid point. How about changing it to LinkedHashSet? It would provide ordering semantics and ensure duplicates are not allowed. Attached is a patch with proposed changes. I have started a build/test run with the changes.

Thanks,
Mitesh
 
Also EclipseLink currently allows users to specify multiple pu-metadata/pu-defaults as long as their metadata match. The only exception to this rule however is all default listeners from all pu-defaults are added to the project.
 
Cheers,
Guy
----- Original Message -----
Sent: Wednesday, April 16, 2008 9:29 PM
Subject: [eclipselink-dev] Fix for bug 227046

Proposed fix for bug  227046  is now available for review.

Please review and provide any feedback.

Please ignore patches added as comments to the bug. I was "learning" to use Bugzilla  :-[

Thanks,
Mitesh


_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev

_______________________________________________ eclipselink-dev mailing list eclipselink-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
Index: src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/EntityAccessor.java
===================================================================
--- src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/EntityAccessor.java	(revision 15182)
+++ src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/EntityAccessor.java	(working copy)
@@ -393,7 +393,7 @@
      * at runtime and have the default listeners available to them.
      */
     protected void processDefaultListeners() {
-        for (EntityListenerMetadata defaultListener : getProject().getDefaultListeners().values()) {
+        for (EntityListenerMetadata defaultListener : getProject().getDefaultListeners()) {
             // We need to clone the default listeners. Can't re-use the 
             // same one for all the entities in the persistence unit.
             EntityListenerMetadata listener = (EntityListenerMetadata) defaultListener.clone();
Index: src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java
===================================================================
--- src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java	(revision 15182)
+++ src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java	(working copy)
@@ -20,6 +20,7 @@
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Set;
+import java.util.LinkedHashSet;
 
 import javax.persistence.GenerationType;
 import javax.persistence.spi.PersistenceUnitInfo;
@@ -125,7 +126,7 @@
 
     // Default listeners that need to be applied to each entity in the
     // persistence unit (unless they exclude them).
-    private HashMap<String, EntityListenerMetadata> m_defaultListeners;
+    private Set<EntityListenerMetadata> m_defaultListeners;
     
     // Metadata converters, that is, EclipseLink converters.
     private HashMap<String, AbstractConverterMetadata> m_converters;
@@ -147,7 +148,7 @@
         m_enableLazyForOneToOne = enableLazyForOneToOne;
         
         m_entityMappings = new ArrayList<XMLEntityMappings>();
-        m_defaultListeners = new HashMap<String, EntityListenerMetadata>();
+        m_defaultListeners = new LinkedHashSet<EntityListenerMetadata>(); // Using a LinkedHashSet as ordering needs to be preserved.
 
         m_namedQueries = new HashMap<String, NamedQueryMetadata>();
         m_namedNativeQueries = new HashMap<String, NamedNativeQueryMetadata>();
@@ -253,7 +254,7 @@
      * INTERNAL:
      */
     public void addDefaultListener(EntityListenerMetadata defaultListener) {
-    	m_defaultListeners.put(defaultListener.getClassName(), defaultListener);
+    	m_defaultListeners.add(defaultListener);
     }
 
     /**
@@ -542,7 +543,7 @@
     /**
      * INTERNAL:
      */
-    public HashMap<String, EntityListenerMetadata> getDefaultListeners() {
+    public Set<EntityListenerMetadata> getDefaultListeners() {
         return m_defaultListeners;
     }
     

Back to the top