Hi,
As I've feared.. Fully Qualified Names in casting not working, throws an identifier expected exception:
package com.test; import java.util.HashMap; import java.util.Map; import javax.persistence.Embeddable; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; public final class F328 { public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("objectdb:$objectdb/db/test4.tmp;drop"); EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); MyEntity entity = new MyEntity(); entity.embeddeds.put("test", new EmbeddedA()); entity.embeddeds.put("test2", new EmbeddedB()); em.persist(entity); em.getTransaction().commit(); // FAIL WITH EXCEPTION HERE query = "SELECT COUNT(e) FROM MyEntity e WHERE ((com.test.F328.EmbeddedB)e.embeddeds.get('test2')).superB = '123'"; System.out.println("4: " + em.createQuery(query).getSingleResult()); em.close(); emf.close(); } @Entity public static final class MyEntity { Map<String, EmbeddedBase> embeddeds = new HashMap<String, EmbeddedBase>(); } @Embeddable public static class EmbeddedBase { String base = "TEST"; } @Embeddable public static class EmbeddedA extends EmbeddedBase { String name = "Alex"; } @Embeddable public static class EmbeddedB extends EmbeddedA { String superB = "123"; } }
Please any help.. I am starting to get really annoyed with all that map related workaround and stuff...
thanks very much!!!
Alex