diff options
author | Pascal Filion | 2012-08-02 18:31:09 +0000 |
---|---|---|
committer | Karen Butzke | 2012-08-02 20:38:01 +0000 |
commit | 955a6e0b22bae80118b72d8fb5018f765659a185 (patch) | |
tree | 0d8e01fbd5a0222ce58130759986f311d3a574c6 | |
parent | 3735aca8b3fdf8e98c08b26be640411a2fb07eeb (diff) | |
download | webtools.dali-955a6e0b22bae80118b72d8fb5018f765659a185.tar.gz webtools.dali-955a6e0b22bae80118b72d8fb5018f765659a185.tar.xz webtools.dali-955a6e0b22bae80118b72d8fb5018f765659a185.zip |
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.java | 23 |
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 ff88a33856..fa7d4a4cb2 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 +} |