OPENJPA-1283 Incorrect SQL for a JPQL query selecting Map value from an elementCollection of a Map and the map the value is an embeddable

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@810744 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Catalina Wei 2009-09-03 00:45:17 +00:00
parent 1908a91180
commit 5d6581bf7f
2 changed files with 17 additions and 1 deletions

View File

@ -33,6 +33,7 @@ import org.apache.openjpa.jdbc.meta.FieldMapping;
import org.apache.openjpa.jdbc.meta.Strategy;
import org.apache.openjpa.jdbc.meta.ValueMapping;
import org.apache.openjpa.jdbc.meta.strats.HandlerCollectionTableFieldStrategy;
import org.apache.openjpa.jdbc.meta.strats.HandlerHandlerMapTableFieldStrategy;
import org.apache.openjpa.jdbc.meta.strats.LRSMapFieldStrategy;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.ForeignKey;
@ -320,7 +321,10 @@ public class PCPath
Strategy strategy = pstate.field.getStrategy();
if (strategy instanceof HandlerCollectionTableFieldStrategy) {
return ((HandlerCollectionTableFieldStrategy) strategy).
getElementColumns(elem.getTypeMapping());
getElementColumns(elem.getTypeMapping());
} else if (strategy instanceof HandlerHandlerMapTableFieldStrategy) {
return ((HandlerHandlerMapTableFieldStrategy) strategy).
getValueColumns(elem.getTypeMapping());
}
}
if (pstate.joinedRel && elem.getTypeCode() == JavaTypes.PC)

View File

@ -182,6 +182,7 @@ public class TestEmbeddable extends SQLListenerTestCase {
public void testMapKeyTemporal() {
createObjMapKeyTemporal();
findObjMapKeyTemporal();
queryObjMapKeyTemporal();
}
public void testEntityA_Embed_MappedToOneCascadeDelete() {
@ -2356,6 +2357,17 @@ public class TestEmbeddable extends SQLListenerTestCase {
assertEquals(3, item.getImages().size());
}
public void queryObjMapKeyTemporal() {
EntityManager em = emf.createEntityManager();
String jpql = "SELECT VALUE(img) FROM Item5 item, IN (item.images) img " +
"WHERE img.fName = :fName and item.id = :id";
Query q = em.createQuery(jpql);
q.setParameter("fName", "file1");
q.setParameter("id", 1);
List coll = q.getResultList();
assertEquals(1, coll.size());
}
public void queryItem(EntityManagerFactory emf) {
EntityManager em = emf.createEntityManager();
EntityTransaction tran = em.getTransaction();