diff options
author | Pascal Filion | 2012-08-02 18:31:09 +0000 |
---|---|---|
committer | Karen Butzke | 2012-08-02 18:31:09 +0000 |
commit | c4f49651eb12fa177bfca8e30568ce42e8f22a22 (patch) | |
tree | 524dc0a5a3d88caf43aadfa7e141b13dd09c8102 | |
parent | bc45980ddddb6861d3ee3e194518d7cd7006e2e6 (diff) | |
download | webtools.dali-c4f49651eb12fa177bfca8e30568ce42e8f22a22.tar.gz webtools.dali-c4f49651eb12fa177bfca8e30568ce42e8f22a22.tar.xz webtools.dali-c4f49651eb12fa177bfca8e30568ce42e8f22a22.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 | 21 |
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 0ae0971e4e..05c50266ac 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(); + } } } } |