candlepin/candlepin — pull request #356 by mstead (2013-08-23 19:07:54+00:00)
Title: 1000444: Fixed find by stack id query

The pool id comparison in the detached criteria was actually comparing
that the attributes pool id was the same as itself, which would yeild a
match for any entitlement after an entitlement was added with the correct
stack id.

The fix was to alias the pool criteria in the main query, and reference it
in the detached criteria. Detached criteria was comparing the attributes
pool.id to iteself, but the main criteria also had pool. Using alias
avoids the common name.