OK.. I'm stuck.
Can someone help me converting this JQL
SELECT a FROM Asset a WHERE ?1 IN (SELECT c FROM a.categories c)
categories is a collection of Enum. I have difficulty converting the 开发者_如何转开发WHERE part. I don't understand why method CriteriaBuilder.IN only receive one value.
Anyone can help me?
Try something like:
CriteriaBuilder qb = em.getCriteriaBuilder();
CriteriaQuery<Asset> cq = qb.createQuery(Asset.class);
Root<Asset> asset = cq.from(Asset.class);
cq.where(qb.parameter(Category.class, "category").in(asset.<Collection<?>>get("categories"))));
Query query = em.createQuery(cq);
精彩评论