开发者

jpa criteriabuilder for @ElementCollection

开发者 https://www.devze.com 2023-03-17 05:06 出处:网络
What\'s the equivalent CriteriaBuilder for this simple jpl? TypedQuery<Sample> query = em.createQuery(\"from Sample s, In(s.friends) f where f = :friend\", Sample.class).setParameter(\"friend\"

What's the equivalent CriteriaBuilder for this simple jpl?

TypedQuery<Sample> query = em.createQuery("from Sample s, In(s.friends) f where f = :friend", Sample.class).setParameter("friend", friend);
// query yields: select sample0_.id as id39_ from Sample sample0_ inner join Sample_friends friends1_ on sample0_.id=friends1_.Sample_id where friends1_.friends=?
return query.getResultList();

I've tried dozens of formulations using .in() .join() and .member() to no avail. .in only works as a where clause not as part of the from. .join seems to require a dereference to an attribute when using in the开发者_运维知识库 where. and .member only works on non-elemental types (full entities as the contained reference). [I can post my vain attempts. I've used the join() mechanism for other collections where the joined object is an entity, but I can't figure out how to use for an element.]

0

精彩评论

暂无评论...
验证码 换一张
取 消