sql - JoinAlias vs. Joinquery over differences toward Rowcount -


from understand, joinalias supposed functionally similar joinquery in ways return object. ie joinalias returns outer iqueryover , joinqueryover returns 1 join object. in following example:

    query.left.joinalias(() => eventalias.children, () => childalias);        query.where(() => childalias.name.isin(searchcriteria.selectednames.toarray())); 

the rowcount 29.

but here:

  query.left.joinqueryover(s => s.children).where(restrictions.in(projections.property<child>(x => x.name),                     searchcriteria.selectednames.toarray())); 

query.rowcount(); returns 18.

the 18 want. there 18 entries on db.

i did research on distinctrootentityresulttransformer() brings count 14 after alias, still not correct.

on high level i'd gain better understanding happening, on immediate level i'd know if need use alias.

thanks

--- edit --- should left join, becuase count can 0, , want parent items. noted in answer, when run exact same filter same join (left) results identical. however, when no 1 searches, still create alias, , without filtering @ getting 29.

the first issue solved andrew. second cartesian product.

check this: nhibernate fetch/fetchmany duplication in resultset, how fix tofuture()

when join root children - result set gets multiplied. there many rows have children. not many have roots.

my suggestion be, use batch-fetching load collections ex-post, query root entity. filter children, use sub-queries...

check how use batch fetching:

how use subquery filter root:

how distinct root entity works?


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -