Hi,

minor detail, but I recently stubled upon the query generated by 
SubjectSearchDAOImpl.getAdminRolesFilter(),
used by search() and count(). Maybe it could be simplified.

It seems to determine all users which have roles not in adminRoles (to be able 
to filter them out
by WHERE subject_id NOT IN ... ).

The generated query looks like (for type==USER and adminRoles={1,2}):

(SELECT syncopeUser_id AS subject_id
                                FROM Membership M1
                                WHERE syncopeRole_id IN
                                        (SELECT syncopeRole_id
                                                FROM Membership M2
                                                WHERE 
M2.syncopeUser_id=M1.syncopeUser_id AND syncopeRole_id NOT IN
                                                        (SELECT id AS 
syncopeRole_id
                                                                FROM SyncopeRole
                                                                WHERE id=1 OR 
id=2
                                                )
                        )


I don't really understand why two (inter-dependent) subqueries on membership 
are needed.
I don't see a difference to

WHERE subject_id NOT IN (
                       SELECT syncopeUser_id AS subject_id FROM Membership M2 
WHERE syncopeRole_id NOT IN (
                                               SELECT id AS syncopeRole_id FROM 
SyncopeRole WHERE id=1 OR id=2
                                   )
            )

... but probably I'm overlooking something?

Cheers, Guido

Reply via email to