result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_MAPKEYANDACTIVITYSTATEID,
finderArgs, this);
}
if (result instanceof LFObjectiveState) {
LFObjectiveState lfObjectiveState = (LFObjectiveState) result;
if (!Validator.equals(mapKey, lfObjectiveState.getMapKey()) ||
!Validator.equals(activityStateID,
lfObjectiveState.getActivityStateID())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFOBJECTIVESTATE_WHERE);
boolean bindMapKey = false;
if (mapKey == null) {
query.append(_FINDER_COLUMN_MAPKEYANDACTIVITYSTATEID_MAPKEY_1);
} else if (mapKey.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_MAPKEYANDACTIVITYSTATEID_MAPKEY_3);
} else {
bindMapKey = true;
if (mapKey.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_MAPKEYANDACTIVITYSTATEID_MAPKEY_3);
} else {
query.append(_FINDER_COLUMN_MAPKEYANDACTIVITYSTATEID_MAPKEY_2);
}
}
if (activityStateID == null) {
query.append(_FINDER_COLUMN_MAPKEYANDACTIVITYSTATEID_ACTIVITYSTATEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_MAPKEYANDACTIVITYSTATEID_ACTIVITYSTATEID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindMapKey) {
if (mapKey != null) {
qPos.add(mapKey);
}
}
if (activityStateID != null) {
qPos.add(activityStateID.intValue());
}
List<LFObjectiveState> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MAPKEYANDACTIVITYSTATEID,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFObjectiveStatePersistenceImpl.fetchByMapKeyAndActivityStateID(String, Integer, boolean) with parameters (" +
StringUtil.merge(finderArgs) +
") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
}
LFObjectiveState lfObjectiveState = list.get(0);
result = lfObjectiveState;
cacheResult(lfObjectiveState);
if ((lfObjectiveState.getMapKey() == null) ||
!lfObjectiveState.getMapKey().equals(mapKey) ||
(lfObjectiveState.getActivityStateID() != activityStateID)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_MAPKEYANDACTIVITYSTATEID,
finderArgs, lfObjectiveState);
}
}
} catch (Exception e) {