protected Object lookupIdentity(IdentityObject obj, EntityManager em) {
Property<?> identityNameProp = modelProperties.get(PROPERTY_IDENTITY_NAME);
Property<?> identityTypeProp = modelProperties.get(PROPERTY_IDENTITY_TYPE);
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<?> criteria = builder.createQuery(identityClass);
Root<?> root = criteria.from(identityClass);
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(builder.equal(root.get(identityNameProp.getName()), obj.getName()));
predicates.add(builder.equal(root.get(identityTypeProp.getName()), lookupIdentityType(obj.getIdentityType().getName(), em)));