sql - Select (and maybe count) entities that contain entries with a specific name -


i'm new query languages. i'm sorry bothering newbie (i guess) question, can't understand how make proper jpql request database.

  • i have entity "a list of items",
  • which has list of "one item entry",
  • which has entity "item",
  • which has field "name".

upd1:

public class listofitems {     protected set<itementry> entries;     // more fields , methods here }  public class itementry {     protected item item;     // more fields , methods here }  public class item {     protected string name;     // more fields , methods here } 

how lists-of-items contain 'item'.name?

i'm stuck @ using in , member of clauses, can't combine them in proper way. progress far is

select l sample$listofitems l l.entries.item.name=?1 

but guess doesn't work cos entries not entity, list...

upd0: maybe somehow add previous query result current? like

def prequery = em.createquery('select e sample$itementry e e.item.name=:name') prequery.setparameter("name", name) def query = em.createquery('select l sample$listofitems l l.entries in :elems') query.setparameter("elems", prequery) 

upd1: saying doesn't work mean yes, throws different kinds of exceptions/ recent 1 can't understand :elems parameter


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -