CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<?> criteria = builder.createQuery(credentialClass);
Root<?> root = criteria.from(credentialClass);
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(builder.equal(root.get(credentialIdentity.getName()),
lookupIdentity(identityObject, em)));
if (credentialType != null) {
if (String.class.equals(credentialType.getJavaClass())) {
predicates.add(builder.equal(root.get(credentialType.getName()),