diff options
author | kmoore | 2012-02-17 14:18:04 +0000 |
---|---|---|
committer | kmoore | 2012-02-17 14:18:04 +0000 |
commit | 089992eab928674f5d310f5ae462f68e78cda36e (patch) | |
tree | 82c30e1045a2197e32e4905756a43cdf85e2d6fd /jpa/plugins/org.eclipse.jpt.jpa.core/src | |
parent | f4003ba897719d4cba3bdf2ea5f3b11f25f65a80 (diff) | |
download | webtools.dali-089992eab928674f5d310f5ae462f68e78cda36e.tar.gz webtools.dali-089992eab928674f5d310f5ae462f68e78cda36e.tar.xz webtools.dali-089992eab928674f5d310f5ae462f68e78cda36e.zip |
bug 369964 - dynamic persistence support
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src')
2 files changed, 37 insertions, 10 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java index e942556bde..4b0cc2e000 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java @@ -223,7 +223,10 @@ public abstract class SpecifiedOrmPersistentAttribute protected JavaPersistentAttribute getCachedJavaAttribute() { JavaResourceType javaResourceType = this.getOwningPersistentTypeJavaType().getJavaResourceType(); - if (getAccess() == AccessType.FIELD) { + if (javaResourceType == null) { + return null; + } + else if (getAccess() == AccessType.FIELD) { JavaResourceField javaResourceField = this.getJavaResourceField(javaResourceType); if (javaResourceField == null) { // nothing in the resource inheritance hierarchy matches our name *and* access type @@ -236,7 +239,7 @@ public abstract class SpecifiedOrmPersistentAttribute } } } - if (getAccess() == AccessType.PROPERTY) { + else if (getAccess() == AccessType.PROPERTY) { JavaResourceMethod javaResourceGetter = this.getJavaResourceGetter(javaResourceType); JavaResourceMethod javaResourceSetter = javaResourceGetter == null ? null : AbstractJavaPersistentType.getValidSiblingSetMethod(javaResourceGetter, javaResourceType.getMethods()); if (javaResourceGetter == null && javaResourceSetter == null) { @@ -261,6 +264,9 @@ public abstract class SpecifiedOrmPersistentAttribute * hierarchy. */ protected JavaResourceField getJavaResourceField(JavaResourceType javaResourceType) { + if (javaResourceType == null) {//checking null here, had a VIRTUAL hierarchy, change AbstractModel to FIELD access, is there another way?? + return null; + } for (JavaResourceField javaResourceField : this.getJavaResourceFields(javaResourceType)) { if (javaResourceField.getName().equals(this.getName())) { return javaResourceField; @@ -354,9 +360,17 @@ public abstract class SpecifiedOrmPersistentAttribute } protected void setDefaultAccess(AccessType access) { - AccessType old = this.defaultAccess; + AccessType oldAccess = this.getAccess(); + AccessType oldDefaultAccess = this.defaultAccess; this.defaultAccess = access; - this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, access); + this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, oldDefaultAccess, access); + if (oldAccess != this.getAccess()) { + //clear out the cached 'javaAttribute' is the access has changed, it will no longer apply + if (this.cachedJavaPersistentAttribute != null) { + this.setJavaPersistentAttribute(null); + this.cachedJavaPersistentAttribute = null; + } + } } protected AccessType buildDefaultAccess() { @@ -373,9 +387,17 @@ public abstract class SpecifiedOrmPersistentAttribute } protected void setSpecifiedAccess_(AccessType access) { - AccessType old = this.specifiedAccess; + AccessType oldAccess = this.getAccess(); + AccessType oldSpecifiedAccess = this.specifiedAccess; this.specifiedAccess = access; - this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, access); + this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, oldSpecifiedAccess, access); + if (oldAccess != this.getAccess()) { + //clear out the cached 'javaAttribute' is the access has changed, it will no longer apply + if (this.cachedJavaPersistentAttribute != null) { + this.setJavaPersistentAttribute(null); + this.cachedJavaPersistentAttribute = null; + } + } } protected AccessType buildSpecifiedAccess() { @@ -393,15 +415,15 @@ public abstract class SpecifiedOrmPersistentAttribute return false; } - public OrmReadOnlyPersistentAttribute convertToVirtual() { - return this.getOwningPersistentType().convertAttributeToVirtual(this); + public OrmReadOnlyPersistentAttribute removeFromXml() { + return this.getOwningPersistentType().removeAttributeFromXml(this); } - public OrmPersistentAttribute convertToSpecified() { + public OrmPersistentAttribute addToXml() { throw new UnsupportedOperationException(); } - public OrmPersistentAttribute convertToSpecified(String mappingKey) { + public OrmPersistentAttribute addToXml(String mappingKey) { throw new UnsupportedOperationException(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java index 46bc58368f..b90206e45a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNullAttributeMapping.java @@ -33,6 +33,11 @@ public class GenericJavaNullAttributeMapping protected String getAnnotationName() { return null; } + + @Override + protected Annotation getAnnotation_() { + return null; + } // ********** metamodel ********** |