result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PACKAGEIDANDSCOPE,
finderArgs, this);
}
if (result instanceof LFPackageScopeRule) {
LFPackageScopeRule lfPackageScopeRule = (LFPackageScopeRule) result;
if (!Validator.equals(packageID, lfPackageScopeRule.getPackageID()) ||
!Validator.equals(scope, lfPackageScopeRule.getScope()) ||
!Validator.equals(scopeID, lfPackageScopeRule.getScopeID())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(5);
query.append(_SQL_SELECT_LFPACKAGESCOPERULE_WHERE);
if (packageID == null) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_PACKAGEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_PACKAGEID_2);
}
boolean bindScope = false;
if (scope == null) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPE_1);
} else if (scope.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPE_3);
} else {
bindScope = true;
if (scope.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPE_3);
} else {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPE_2);
}
}
boolean bindScopeID = false;
if (scopeID == null) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPEID_1);
} else if (scopeID.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPEID_3);
} else {
bindScopeID = true;
if (scopeID.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPEID_3);
} else {
query.append(_FINDER_COLUMN_PACKAGEIDANDSCOPE_SCOPEID_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (packageID != null) {
qPos.add(packageID.intValue());
}
if (bindScope) {
if (scope != null) {
qPos.add(scope);
}
}
if (bindScopeID) {
if (scopeID != null) {
qPos.add(scopeID);
}
}
List<LFPackageScopeRule> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PACKAGEIDANDSCOPE,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFPackageScopeRulePersistenceImpl.fetchByPackageIDAndScope(Integer, String, 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.");
}
LFPackageScopeRule lfPackageScopeRule = list.get(0);
result = lfPackageScopeRule;
cacheResult(lfPackageScopeRule);
if ((lfPackageScopeRule.getPackageID() != packageID) ||
(lfPackageScopeRule.getScope() == null) ||
!lfPackageScopeRule.getScope().equals(scope) ||
(lfPackageScopeRule.getScopeID() == null) ||
!lfPackageScopeRule.getScopeID().equals(scopeID)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PACKAGEIDANDSCOPE,
finderArgs, lfPackageScopeRule);
}
}
} catch (Exception e) {