0
我遇到一些麻烦设置以下查询where
条款:标准的API集谓词的where子句MapJoin
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Configuration> cq = cb.createQuery(Configuration.class);
Root<Configuration> conf = cq.from(Configuration.class);
MapJoin<Configuration, String, Component> mapJoin = conf.join(Configuration_.components, JoinType.LEFT);
cq.where(cb.and(cb.like(mapJoin.key(), "%abc%"),
cb.like(mapJoin.value().get(Component_.displayName), "%def%")));
cq.select(pc);
我基本上是试图让包含在组件的条目中的所有配置 - 键包含“abc”且其值包含“def”的映射。 我期望这个工作,基于从http://blogs.oracle.com/ldemichiel/entry/java_persistence_2_0_proposed,部分Maps
的示例代码,但显然我错过了一些东西。
实体具有以下结构:
@Entity
public class Configuration{
@Id
protected Long id;
@OneToMany
protected Map<String, Component> components;
}
和
@Entity
public class Component{
@Id
protected Long id;
protected String displayName;
}
预先感谢您,感谢任何帮助。
谢谢,这让我走向了正确的方向 – glasspill 2012-02-07 20:51:20