Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2008-11-14 21:08:06 +0000
committertle2008-11-14 21:08:06 +0000
commita8ef170826d966afc729cd08a84620f278bc8da0 (patch)
tree6fe225d9dc55d60b26b56bb035e5175ea77e6436
parentb70b07c9803e1a7f37cbcfc680080078d3c40603 (diff)
downloadwebtools.dali-a8ef170826d966afc729cd08a84620f278bc8da0.tar.gz
webtools.dali-a8ef170826d966afc729cd08a84620f278bc8da0.tar.xz
webtools.dali-a8ef170826d966afc729cd08a84620f278bc8da0.zip
255149 - Bogus property merging in GenericPersistenceUnit.updateProperties()
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java48
1 files changed, 29 insertions, 19 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
index 7edf19e217..e82994c48d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -50,7 +50,6 @@ import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.HashBag;
import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.ReadOnlyCompositeListIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
@@ -995,38 +994,49 @@ public class AbstractPersistenceUnit extends AbstractXmlContextNode
protected void updateExcludeUnlistedClasses(XmlPersistenceUnit persistenceUnit) {
setSpecifiedExcludeUnlistedClasses(persistenceUnit.getExcludeUnlistedClasses());
}
-
+
protected void updateProperties(XmlPersistenceUnit persistenceUnit) {
- XmlProperties xmlProperties = persistenceUnit.getProperties();
-
- Iterator<Property> stream = properties();
- Iterator<XmlProperty> stream2;
-
- if (xmlProperties == null) {
- stream2 = EmptyIterator.instance();
- }
- else {
- stream2 = new CloneIterator<XmlProperty>(xmlProperties.getProperties());//avoid ConcurrentModificationException
- }
+ List<XmlProperty> xmlProperties = this.buildXmlProperties(persistenceUnit);
+ Iterator<Property> stream = this.properties();
while (stream.hasNext()) {
Property property = stream.next();
- if (stream2.hasNext()) {
- property.update(stream2.next());
+ XmlProperty xmlProperty = this.getXmlPropertyNamed(property.getName(), xmlProperties);
+ if (xmlProperty != null) {
+ property.update(xmlProperty);
+
+ xmlProperties.remove(xmlProperty);
}
else {
- removeProperty_(property);
+ this.removeProperty_(property);
}
}
-
- while (stream2.hasNext()) {
- addProperty_(buildProperty(stream2.next()));
+
+ for (XmlProperty xmlProperty : xmlProperties) {
+ this.addProperty_(this.buildProperty(xmlProperty));
}
}
protected Property buildProperty(XmlProperty xmlProperty) {
return getJpaFactory().buildProperty(this, xmlProperty);
}
+
+ protected List<XmlProperty> buildXmlProperties(XmlPersistenceUnit persistenceUnit) {
+ if (persistenceUnit.getProperties() == null) {
+ return new ArrayList<XmlProperty>();
+ }
+ return CollectionTools.list(persistenceUnit.getProperties().getProperties());
+ }
+
+ protected XmlProperty getXmlPropertyNamed(String name, List<XmlProperty> xmlProperties) {
+ for(XmlProperty xmlProperty : xmlProperties) {
+ String xmlPropertyName = xmlProperty.getName();
+ if(xmlPropertyName == name || xmlPropertyName.equals(name)) {
+ return xmlProperty;
+ };
+ }
+ return null;
+ }
protected void updatePersistenceUnitDefaults() {
MappingFilePersistenceUnitDefaults defaults = getPersistenceUnitDefaults();

Back to the top