Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2009-11-18 09:41:11 -0500
committerkmoore2009-11-18 09:41:11 -0500
commit84cbd538d6aca4a5bcdb7e64b1dcf37c08b738af (patch)
tree836cc14177b92e398cd4b9f577efdcf9c06119fa
parent01c013d19462e26f125d19cb8a51882445132be2 (diff)
downloadwebtools.dali-84cbd538d6aca4a5bcdb7e64b1dcf37c08b738af.tar.gz
webtools.dali-84cbd538d6aca4a5bcdb7e64b1dcf37c08b738af.tar.xz
webtools.dali-84cbd538d6aca4a5bcdb7e64b1dcf37c08b738af.zip
rebuild the entity mappings object when the resource type changes, did this for persistence.xml last week
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java
index a734124bff..47852a7a1e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java
@@ -36,7 +36,8 @@ public class GenericOrmXml
protected JpaXmlResource xmlResource;
protected EntityMappings entityMappings;
-
+
+ protected JpaResourceType resourceType;
public GenericOrmXml(MappingFileRef parent, JpaXmlResource resource) {
super(parent);
@@ -48,6 +49,10 @@ public class GenericOrmXml
if (xmlEntityMappings != null) {
this.entityMappings = this.buildEntityMappings(xmlEntityMappings);
}
+ if (resource.getRootObject() != null) {
+ this.entityMappings = buildEntityMappings((XmlEntityMappings) resource.getRootObject());
+ this.resourceType = resource.getResourceType();
+ }
}
@@ -135,11 +140,12 @@ public class GenericOrmXml
XmlEntityMappings oldXmlEntityMappings =
(this.entityMappings == null) ? null : this.entityMappings.getXmlEntityMappings();
XmlEntityMappings newXmlEntityMappings = (XmlEntityMappings) this.xmlResource.getRootObject();
+ JpaResourceType newResourceType = xmlResource.getResourceType();
// if the old and new xml entity mappings are different instances,
// we scrap the old and rebuild. this can happen when the resource
// model drastically changes, such as a cvs checkout or an edit reversion
- if (oldXmlEntityMappings != newXmlEntityMappings) {
+ if (oldXmlEntityMappings != newXmlEntityMappings || newXmlEntityMappings == null || valuesAreDifferent(this.resourceType, newResourceType)) {
if (this.entityMappings != null) {
this.getJpaFile(this.xmlResource.getFile()).removeRootStructureNode(this.xmlResource);
this.entityMappings.dispose();
@@ -149,12 +155,13 @@ public class GenericOrmXml
if (newXmlEntityMappings != null) {
if (this.entityMappings != null) {
- this.getJpaFile(this.xmlResource.getFile()).addRootStructureNode(this.xmlResource, this.entityMappings);
this.entityMappings.update();
} else {
this.setEntityMappings(this.buildEntityMappings(newXmlEntityMappings));
}
+ this.getJpaFile(this.xmlResource.getFile()).addRootStructureNode(this.xmlResource, this.entityMappings);
}
+ this.resourceType = newResourceType;
}
protected EntityMappings buildEntityMappings(XmlEntityMappings xmlEntityMappings) {

Back to the top