public static Specification<JpaTarget> hasTag(final Long tagId) {

        return (targetRoot, query, cb) -> {
            final SetJoin<JpaTarget, JpaTargetTag> tags = targetRoot.join(JpaTarget_.tags, JoinType.LEFT);
            return cb.equal(tags.get(JpaTargetTag_.id), tagId);
        };
    }
public static Specification < JpaTarget > hasTag ( final Long tagId ) { return ( targetRoot , query , cb ) -> { final SetJoin < JpaTarget , JpaTargetTag > tags = targetRoot . join ( JpaTarget_ . tags , JoinType . LEFT ) ; return cb . equal ( tags . get ( JpaTargetTag_ . id ) , tagId ) ; } ; }
{@link Specification} for retrieving {@link Target}s by tag.

@param tagId
the ID of the distribution set which must be assigned
@return the {@link Target} {@link Specification}