Additionally to @lansana answer, the problem is when doing
vendedores v
LEFT JOIN v.lojas l ON l.franquia.voToken = :tokenFranquia AND v.voId = :voId
I'm not just taking the sellers whose dont match voToken and voId, I'm also taking sellers without a store, because:
vendedores v LEFT JOIN v.lojas l ON ...
Will be translated to something like:
vendedores v LEFT JOIN vendedores_lojas vl ON vl.vendedor_system_id = v.system_id AND (the ON condition in JPQL)