4
我在尋找JPA 2個標準相當於該JPQL查詢的查詢地圖!使用JPA 2.0標準
我在尋找JPA 2個標準相當於該JPQL查詢的查詢地圖!使用JPA 2.0標準
沒有測試,但我想這應該是OK:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Entity> criteria = cb.createQuery(Entity.class);
Root<Entity> entity = criteria.from(Entity.class);
MapJoin<Entity, String, String> mapJoin = entity.joinMap(Entity_.myMap);
criteria.where(cb.and(cb.equal(mapJoin.key(), "myKey"),
cb.equal(mapJoin.value(), "myValue")));
非常感謝你的回答,它編譯! 不幸的是我現在得到這個bug:http://stackoverflow.com/questions/5580614/jpa-criteriabuilder-join-maps ... – Albataur
看看這個答案:http://stackoverflow.com/questions/6246735/hibernate-jpa2-h2-querying-elementcollections- hashmap-by-key – nowaq