summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Filion2012-08-02 14:31:09 (EDT)
committer Karen Butzke2012-08-02 16:38:01 (EDT)
commit955a6e0b22bae80118b72d8fb5018f765659a185 (patch)
tree0d8e01fbd5a0222ce58130759986f311d3a574c6
parent3735aca8b3fdf8e98c08b26be640411a2fb07eeb (diff)
downloadwebtools.dali-955a6e0b22bae80118b72d8fb5018f765659a185.zip
webtools.dali-955a6e0b22bae80118b72d8fb5018f765659a185.tar.gz
webtools.dali-955a6e0b22bae80118b72d8fb5018f765659a185.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.java23
1 files changed, 16 insertions, 7 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 ff88a33..fa7d4a4 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();
+ }
}
}
}
@@ -359,4 +368,4 @@ public abstract class JpaMapping implements IMapping {
sb.append(getMappingType());
return sb.toString();
}
-} \ No newline at end of file
+}