summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Filion2012-08-02 14:31:09 (EDT)
committerKaren Butzke2012-08-02 14:31:09 (EDT)
commitc4f49651eb12fa177bfca8e30568ce42e8f22a22 (patch)
tree524dc0a5a3d88caf43aadfa7e141b13dd09c8102
parentbc45980ddddb6861d3ee3e194518d7cd7006e2e6 (diff)
downloadwebtools.dali-c4f49651eb12fa177bfca8e30568ce42e8f22a22.zip
webtools.dali-c4f49651eb12fa177bfca8e30568ce42e8f22a22.tar.gz
webtools.dali-c4f49651eb12fa177bfca8e30568ce42e8f22a22.tar.bz2
382150 - ClassCastExpression in JpaMapping when the mapping type is
ElementCollection
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/spi/JpaMapping.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/spi/JpaMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/spi/JpaMapping.java
index 0ae0971..05c5026 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/spi/JpaMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/spi/JpaMapping.java
@@ -26,6 +26,7 @@ import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.persistence.jpa.jpql.spi.IEntity;
import org.eclipse.persistence.jpa.jpql.spi.IManagedType;
import org.eclipse.persistence.jpa.jpql.spi.IMapping;
@@ -123,12 +124,20 @@ public abstract class JpaMapping implements IMapping {
// For relationship mapping, make sure to check the target entity first
if (isRelationship()) {
- String entityName = ((RelationshipMapping) mapping).getTargetEntity();
-
- if (StringTools.stringIsNotEmpty(entityName)) {
- IEntity entity = getParent().getProvider().getEntityNamed(entityName);
- if (entity != null) {
- return entity.getType();
+ if (mappingType == ELEMENT_COLLECTION) {
+ String targetClass = ((ElementCollectionMapping2_0) mapping).getTargetClass();
+ if (StringTools.stringIsNotEmpty(targetClass)) {
+ return getTypeRepository().getType(targetClass);
+ }
+ }
+ else {
+ String entityName = ((RelationshipMapping) mapping).getTargetEntity();
+
+ if (StringTools.stringIsNotEmpty(entityName)) {
+ IEntity entity = getParent().getProvider().getEntityNamed(entityName);
+ if (entity != null) {
+ return entity.getType();
+ }
}
}
}