result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_TREEIDANDMAPKEY,
finderArgs, this);
}
if (result instanceof LFGlobalObjectiveState) {
LFGlobalObjectiveState lfGlobalObjectiveState = (LFGlobalObjectiveState) result;
if (!Validator.equals(treeID, lfGlobalObjectiveState.getTreeID()) ||
!Validator.equals(mapKey, lfGlobalObjectiveState.getMapKey())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFGLOBALOBJECTIVESTATE_WHERE);
if (treeID == null) {
query.append(_FINDER_COLUMN_TREEIDANDMAPKEY_TREEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_TREEIDANDMAPKEY_TREEID_2);
}
boolean bindMapKey = false;
if (mapKey == null) {
query.append(_FINDER_COLUMN_TREEIDANDMAPKEY_MAPKEY_1);
} else if (mapKey.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_TREEIDANDMAPKEY_MAPKEY_3);
} else {
bindMapKey = true;
if (mapKey.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_TREEIDANDMAPKEY_MAPKEY_3);
} else {
query.append(_FINDER_COLUMN_TREEIDANDMAPKEY_MAPKEY_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (treeID != null) {
qPos.add(treeID.intValue());
}
if (bindMapKey) {
if (mapKey != null) {
qPos.add(mapKey);
}
}
List<LFGlobalObjectiveState> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TREEIDANDMAPKEY,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFGlobalObjectiveStatePersistenceImpl.fetchByTreeIDAndMapKey(Integer, String, 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.");
}
LFGlobalObjectiveState lfGlobalObjectiveState = list.get(0);
result = lfGlobalObjectiveState;
cacheResult(lfGlobalObjectiveState);
if ((lfGlobalObjectiveState.getTreeID() != treeID) ||
(lfGlobalObjectiveState.getMapKey() == null) ||
!lfGlobalObjectiveState.getMapKey().equals(mapKey)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TREEIDANDMAPKEY,
finderArgs, lfGlobalObjectiveState);
}
}
} catch (Exception e) {