fieldsToSelect = new HashSet<String>(selectFieldList);
}
if (fieldsToSelect != null && useCache) {
String errMsg = "Error running script " + ctxHelper.getScriptName() + ": Problem invoking the findOne method: Cannot specify selectFieldList argument when useCache is set to true ";
Debug.logWarning(errMsg, module);
throw new ScriptException(errMsg);
}
GenericValue valueOut = null;
GenericPK entityPK = delegator.makePK(modelEntity.getEntityName(), entityContext);
if (entityPK.containsPrimaryKey(true)) {
try {
if (useCache) {
valueOut = delegator.findOne(entityPK.getEntityName(), entityPK, true);
} else {
if (fieldsToSelect != null) {
valueOut = delegator.findByPrimaryKeyPartial(entityPK, fieldsToSelect);
} else {
valueOut = delegator.findOne(entityPK.getEntityName(), entityPK, false);
}
}
} catch (GenericEntityException e) {
String errMsg = "Error running script " + ctxHelper.getScriptName() + ": Problem invoking the findOne method: " + e.getMessage();
Debug.logWarning(e, errMsg, module);
throw new ScriptException(errMsg);
}
} else {
if (Debug.warningOn()) {
Debug.logWarning("Error running script " + ctxHelper.getScriptName() + ": Returning null because found incomplete primary key in find: " + entityPK, module);
}