java - How to JPA join from child element -


i want select elements via jpa query/criteriaquery can't quite figure out how it.

i'm using h2 db. query i've tested in h2 console is:

select element.*  element left join group_element on element.id  = group_element.elements_id group_id null 

in other words want select groupless elements.

classes are:

@entity class element{     @id     @generatedvalue     private integer id; }  @entity class group{     @id     @generatedvalue     private integer id;      @manytomany     private list<element> elements; } 

i've had no problem doing in similar cases "elements" mapped field in element, in specific case can't add field. can't quite figure out how join entities in case.

jql joins owner owned. groupless elements do

select e element e e not in (select e2 group g inner join g.elements e2) 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -