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