I would like to do this but with the criteria API instead:
select count(distinct e) from Event e, IN(e.userAccessPermissions) p where p.principal = :principal an
Use c.distinct(true) on your Query.
See http://relation.to/Bloggers/ATypesafeCriteriaQueryAPIForJPA for more samples.