result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_COURSEIDANDUSERID,
finderArgs, this);
}
if (result instanceof LFCourse) {
LFCourse lfCourse = (LFCourse) result;
if (!Validator.equals(courseID, lfCourse.getCourseID()) ||
!Validator.equals(userID, lfCourse.getUserID())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFCOURSE_WHERE);
if (courseID == null) {
query.append(_FINDER_COLUMN_COURSEIDANDUSERID_COURSEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_COURSEIDANDUSERID_COURSEID_2);
}
if (userID == null) {
query.append(_FINDER_COLUMN_COURSEIDANDUSERID_USERID_NULL_2);
} else {
query.append(_FINDER_COLUMN_COURSEIDANDUSERID_USERID_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (courseID != null) {
qPos.add(courseID.intValue());
}
if (userID != null) {
qPos.add(userID.intValue());
}
List<LFCourse> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_COURSEIDANDUSERID,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFCoursePersistenceImpl.fetchByCourseIdAndUserId(Integer, 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.");
}
LFCourse lfCourse = list.get(0);
result = lfCourse;
cacheResult(lfCourse);
if ((lfCourse.getCourseID() != courseID) ||
(lfCourse.getUserID() != userID)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_COURSEIDANDUSERID,
finderArgs, lfCourse);
}
}
} catch (Exception e) {