try {
GenericValue valueOut = null;
GenericPK entityPK = delegator.makePK(modelEntity.getEntityName(), entityContext);
// make sure we have a full primary key, if any field is null then just log a warning and return null instead of blowing up
if (entityPK.containsPrimaryKey(true)) {
if (useCache) {
valueOut = delegator.findOne(entityPK.getEntityName(), entityPK, true);
} else {
if (fieldsToSelect != null) {
valueOut = delegator.findByPrimaryKeyPartial(entityPK, fieldsToSelect);