Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornhauge2012-02-27 22:52:55 +0000
committernhauge2012-02-27 22:52:55 +0000
commitba69c1253e69f97fc0799bc85002ffa2eb526cbd (patch)
tree5ce0697af510b9dd0719526b2f4c7361d620f5a4
parent546fe55e9649a7f7ea05e577c996044cc0c4b547 (diff)
downloadwebtools.dali-ba69c1253e69f97fc0799bc85002ffa2eb526cbd.tar.gz
webtools.dali-ba69c1253e69f97fc0799bc85002ffa2eb526cbd.tar.xz
webtools.dali-ba69c1253e69f97fc0799bc85002ffa2eb526cbd.zip
305591- mappedBy choices should not include transients.
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/RelationshipMapping.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/TypeMapping.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java12
12 files changed, 77 insertions, 18 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/RelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/RelationshipMapping.java
index 350e09e7d5..91af97e6f5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/RelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/RelationshipMapping.java
@@ -55,6 +55,12 @@ public interface RelationshipMapping
* resolves
*/
Iterable<String> getAllTargetEntityAttributeNames();
+
+ /**
+ * Return the names of non-transient attribute mappings on the target entity,
+ * provided target entity resolves
+ */
+ Iterable<String> getTargetEntityNonTransientAttributeNames();
/**
* Return the char to be used for browsing or creating the target entity IType.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/TypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/TypeMapping.java
index 160307c820..3cae9b1db6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/TypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/TypeMapping.java
@@ -166,6 +166,12 @@ public interface TypeMapping
* inheritance hierarchy.
*/
Iterable<AttributeMapping> getAllAttributeMappings();
+
+ /**
+ * Return all the non-transient attribute mappings in the type mapping's
+ * inheritance hierarchy
+ */
+ Iterable<AttributeMapping> getNonTransientAttributeMappings();
/**
* Return attribute mappings of a particular mapping type that are declared anywhere on this
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
index cb0cf45145..639dbd3329 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
@@ -937,7 +937,7 @@ public abstract class AbstractJavaMultiRelationshipMapping<A extends Relationshi
}
public Iterable<String> getCandidateMapKeyNames() {
- return this.getAllTargetEntityAttributeNames();
+ return this.getTargetEntityNonTransientAttributeNames();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java
index 78985671a8..46b2334dfb 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java
@@ -265,6 +265,20 @@ public abstract class AbstractJavaRelationshipMapping<A extends RelationshipMapp
return (entity != null) ? entity.getAllAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
}
+ // Get the names of non-transient attribute mappings
+ public Iterable<String> getTargetEntityNonTransientAttributeNames() {
+ return new CompositeIterable<String>(this.getTargetEntityNonTransientAttributeNamesLists());
+ }
+
+ protected Iterable<Iterable<String>> getTargetEntityNonTransientAttributeNamesLists() {
+ return new TransformationIterable<AttributeMapping, Iterable<String>>(this.getTargetEntityNonTransientAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
+ }
+
+ protected Iterable<AttributeMapping> getTargetEntityNonTransientAttributeMappings() {
+ Entity entity = this.getResolvedTargetEntity();
+ return (entity != null) ? entity.getNonTransientAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
+ }
+
protected String getTargetEntityIdAttributeName() {
PersistentAttribute attribute = this.getTargetEntityIdAttribute();
return (attribute == null) ? null : attribute.getName();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
index f65741e11e..0bb739537c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
@@ -21,6 +21,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
+import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.Column;
import org.eclipse.jpt.jpa.core.context.Entity;
@@ -212,6 +213,14 @@ public abstract class AbstractJavaTypeMapping<A extends Annotation>
return true;
}
+ public Iterable<AttributeMapping> getNonTransientAttributeMappings() {
+ return new FilteringIterable<AttributeMapping>(this.getAllAttributeMappings()) {
+ @Override
+ protected boolean accept(AttributeMapping attributeMapping) {
+ return (attributeMapping.getKey() != MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ }
+ };
+ }
// ********** attribute overrides **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
index 9189b3bfe6..e0b0f2c6a0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
@@ -183,7 +183,7 @@ public class GenericJavaMappedByRelationshipStrategy
}
public Iterable<String> getCandidateMappedByAttributeNames() {
- return this.getRelationshipMapping().getAllTargetEntityAttributeNames();
+ return this.getRelationshipMapping().getTargetEntityNonTransientAttributeNames();
}
protected Iterable<String> getCandidateMappedByAttributeNames(Filter<String> filter) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
index efc55baaf0..b4f51809e1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
@@ -864,7 +864,7 @@ public abstract class AbstractOrmMultiRelationshipMapping<X extends AbstractXmlM
}
public Iterable<String> getCandidateMapKeyNames() {
- return this.getAllTargetEntityAttributeNames();
+ return this.getTargetEntityNonTransientAttributeNames();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
index 0e7500f92a..dc5c664ff3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
@@ -287,6 +287,20 @@ public abstract class AbstractOrmRelationshipMapping<X extends AbstractXmlRelati
return (entity != null) ? entity.getAllAttributeMappings() : EmptyIterable.<AttributeMapping>instance();
}
+ // Get the name of non-transient attribute mappings
+ public Iterable<String> getTargetEntityNonTransientAttributeNames() {
+ return new CompositeIterable<String>(this.getNonTransientTargetEntityAttributeNamesLists());
+ }
+
+ protected Iterable<Iterable<String>> getNonTransientTargetEntityAttributeNamesLists() {
+ return new TransformationIterable<AttributeMapping, Iterable<String>>(this.getNonTransientTargetEntityAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
+ }
+
+ protected Iterable<AttributeMapping> getNonTransientTargetEntityAttributeMappings() {
+ Entity entity = this.getResolvedTargetEntity();
+ return (entity != null) ? entity.getNonTransientAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
+ }
+
protected String getTargetEntityIdAttributeName() {
PersistentAttribute attribute = this.getTargetEntityIdAttribute();
return (attribute == null) ? null : attribute.getName();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
index 1a8a0aeecb..2ca8e87cd6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
@@ -23,6 +23,7 @@ import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.Column;
import org.eclipse.jpt.jpa.core.context.Entity;
@@ -300,6 +301,15 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
};
}
+ public Iterable<AttributeMapping> getNonTransientAttributeMappings() {
+ return new FilteringIterable<AttributeMapping>(this.getAllAttributeMappings()) {
+ @Override
+ protected boolean accept(AttributeMapping attributeMapping) {
+ return (attributeMapping.getKey() != MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
+ }
+ };
+ }
+
public Column resolveOverriddenColumn(String attributeName) {
for (AttributeMapping attributeMapping : this.getAttributeMappings()) {
Column column = attributeMapping.resolveOverriddenColumn(attributeName);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
index 77a8eb8aa0..751f3ce4de 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
@@ -152,7 +152,7 @@ public class GenericOrmMappedByRelationshipStrategy
}
public Iterable<String> getCandidateMappedByAttributeNames() {
- return this.getRelationshipMapping().getAllTargetEntityAttributeNames();
+ return this.getRelationshipMapping().getTargetEntityNonTransientAttributeNames();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java
index b4dcab4157..9e9a74fb1d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java
@@ -1224,25 +1224,25 @@ public abstract class AbstractJavaElementCollectionMapping2_0
// ********** embedded mappings **********
public Iterable<String> getCandidateMapKeyNames() {
- return this.getAllTargetEmbeddableAttributeNames();
+ return this.getAllTargetEmbeddableNonTransientAttributeNames();
}
- protected Iterable<String> getAllTargetEmbeddableAttributeNames() {
- return new CompositeIterable<String>(this.getAllTargetEmbeddableAttributeNamesLists());
+ protected Iterable<String> getAllTargetEmbeddableNonTransientAttributeNames() {
+ return new CompositeIterable<String>(this.getTargetEmbeddableNonTransientAttributeNamesLists());
}
/**
* Return a list of lists; each nested list holds the names for one of the
* embedded mapping's target embeddable type mapping's attribute mappings
- * (attribute or association mappings, depending on the specified transformer).
+ * (non-transient attribute or association mappings, depending on the specified transformer).
*/
- protected Iterable<Iterable<String>> getAllTargetEmbeddableAttributeNamesLists() {
- return new TransformationIterable<AttributeMapping, Iterable<String>>(this.getAllTargetEmbeddableAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
+ protected Iterable<Iterable<String>> getTargetEmbeddableNonTransientAttributeNamesLists() {
+ return new TransformationIterable<AttributeMapping, Iterable<String>>(this.getTargetEmbeddableNonTransientAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
}
- protected Iterable<AttributeMapping> getAllTargetEmbeddableAttributeMappings() {
+ protected Iterable<AttributeMapping> getTargetEmbeddableNonTransientAttributeMappings() {
Embeddable targetEmbeddable = this.getResolvedTargetEmbeddable();
- return (targetEmbeddable != null) ? targetEmbeddable.getAllAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
+ return (targetEmbeddable != null) ? targetEmbeddable.getNonTransientAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
index f1128df806..2747edbaf2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java
@@ -1244,21 +1244,21 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen
// ********** embedded mappings **********
public Iterable<String> getCandidateMapKeyNames() {
- return new CompositeIterable<String>(this.getAllTargetEmbeddableAttributeNamesLists());
+ return new CompositeIterable<String>(this.getTargetEmbeddableNonTransientAttributeNamesLists());
}
/**
* Return a list of lists; each nested list holds the names for one of the
* embedded mapping's target embeddable type mapping's attribute mappings
- * (attribute or association mappings, depending on the specified transformer).
+ * (non-transient attribute or association mappings, depending on the specified transformer).
*/
- protected Iterable<Iterable<String>> getAllTargetEmbeddableAttributeNamesLists() {
- return new TransformationIterable<AttributeMapping, Iterable<String>>(this.getAllTargetEmbeddableAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
+ protected Iterable<Iterable<String>> getTargetEmbeddableNonTransientAttributeNamesLists() {
+ return new TransformationIterable<AttributeMapping, Iterable<String>>(this.getTargetEmbeddableNonTransientAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
}
- protected Iterable<AttributeMapping> getAllTargetEmbeddableAttributeMappings() {
+ protected Iterable<AttributeMapping> getTargetEmbeddableNonTransientAttributeMappings() {
Embeddable targetEmbeddable = this.getResolvedTargetEmbeddable();
- return (targetEmbeddable != null) ? targetEmbeddable.getAllAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
+ return (targetEmbeddable != null) ? targetEmbeddable.getNonTransientAttributeMappings() : EmptyIterable.<AttributeMapping> instance();
}
@Override

Back to the top