result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_SCOPEANDISDEFAULT,
finderArgs, this);
}
if (result instanceof LFPackageScopeRule) {
LFPackageScopeRule lfPackageScopeRule = (LFPackageScopeRule) result;
if (!Validator.equals(scope, lfPackageScopeRule.getScope()) ||
!Validator.equals(scopeID, lfPackageScopeRule.getScopeID()) ||
!Validator.equals(isDefault,
lfPackageScopeRule.getIsDefault())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(5);
query.append(_SQL_SELECT_LFPACKAGESCOPERULE_WHERE);
boolean bindScope = false;
if (scope == null) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPE_1);
} else if (scope.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPE_3);
} else {
bindScope = true;
if (scope.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPE_3);
} else {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPE_2);
}
}
boolean bindScopeID = false;
if (scopeID == null) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPEID_1);
} else if (scopeID.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPEID_3);
} else {
bindScopeID = true;
if (scopeID.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPEID_3);
} else {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_SCOPEID_2);
}
}
if (isDefault == null) {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_ISDEFAULT_NULL_2);
} else {
query.append(_FINDER_COLUMN_SCOPEANDISDEFAULT_ISDEFAULT_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindScope) {
if (scope != null) {
qPos.add(scope);
}
}
if (bindScopeID) {
if (scopeID != null) {
qPos.add(scopeID);
}
}
if (isDefault != null) {
qPos.add(isDefault.booleanValue());
}
List<LFPackageScopeRule> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SCOPEANDISDEFAULT,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFPackageScopeRulePersistenceImpl.fetchByScopeAndIsDefault(String, String, Boolean, 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.");
}
LFPackageScopeRule lfPackageScopeRule = list.get(0);
result = lfPackageScopeRule;
cacheResult(lfPackageScopeRule);
if ((lfPackageScopeRule.getScope() == null) ||
!lfPackageScopeRule.getScope().equals(scope) ||
(lfPackageScopeRule.getScopeID() == null) ||
!lfPackageScopeRule.getScopeID().equals(scopeID) ||
(lfPackageScopeRule.getIsDefault() != isDefault)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_SCOPEANDISDEFAULT,
finderArgs, lfPackageScopeRule);
}
}
} catch (Exception e) {