result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_GRADE,
finderArgs, this);
}
if (result instanceof LFPackageGradeStorage) {
LFPackageGradeStorage lfPackageGradeStorage = (LFPackageGradeStorage) result;
if (!Validator.equals(userId, lfPackageGradeStorage.getUserId()) ||
!Validator.equals(packageId,
lfPackageGradeStorage.getPackageId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFPACKAGEGRADESTORAGE_WHERE);
if (userId == null) {
query.append(_FINDER_COLUMN_GRADE_USERID_NULL_2);
} else {
query.append(_FINDER_COLUMN_GRADE_USERID_2);
}
if (packageId == null) {
query.append(_FINDER_COLUMN_GRADE_PACKAGEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_GRADE_PACKAGEID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (userId != null) {
qPos.add(userId.longValue());
}
if (packageId != null) {
qPos.add(packageId.longValue());
}
List<LFPackageGradeStorage> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_GRADE,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFPackageGradeStoragePersistenceImpl.fetchByGrade(Long, Long, 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.");
}
LFPackageGradeStorage lfPackageGradeStorage = list.get(0);
result = lfPackageGradeStorage;
cacheResult(lfPackageGradeStorage);
if ((lfPackageGradeStorage.getUserId() != userId) ||
(lfPackageGradeStorage.getPackageId() != packageId)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_GRADE,
finderArgs, lfPackageGradeStorage);
}
}
} catch (Exception e) {