result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_QUIZANDELEMENTID,
finderArgs, this);
}
if (result instanceof LFQuizTreeElement) {
LFQuizTreeElement lfQuizTreeElement = (LFQuizTreeElement) result;
if (!Validator.equals(quizID, lfQuizTreeElement.getQuizID()) ||
!Validator.equals(elementID,
lfQuizTreeElement.getElementID())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFQUIZTREEELEMENT_WHERE);
if (quizID == null) {
query.append(_FINDER_COLUMN_QUIZANDELEMENTID_QUIZID_NULL_2);
} else {
query.append(_FINDER_COLUMN_QUIZANDELEMENTID_QUIZID_2);
}
boolean bindElementID = false;
if (elementID == null) {
query.append(_FINDER_COLUMN_QUIZANDELEMENTID_ELEMENTID_1);
} else if (elementID.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_QUIZANDELEMENTID_ELEMENTID_3);
} else {
bindElementID = true;
if (elementID.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_QUIZANDELEMENTID_ELEMENTID_3);
} else {
query.append(_FINDER_COLUMN_QUIZANDELEMENTID_ELEMENTID_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (quizID != null) {
qPos.add(quizID.intValue());
}
if (bindElementID) {
if (elementID != null) {
qPos.add(elementID);
}
}
List<LFQuizTreeElement> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_QUIZANDELEMENTID,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFQuizTreeElementPersistenceImpl.fetchByQuizAndElementID(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.");
}
LFQuizTreeElement lfQuizTreeElement = list.get(0);
result = lfQuizTreeElement;
cacheResult(lfQuizTreeElement);
if ((lfQuizTreeElement.getQuizID() != quizID) ||
(lfQuizTreeElement.getElementID() == null) ||
!lfQuizTreeElement.getElementID().equals(elementID)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_QUIZANDELEMENTID,
finderArgs, lfQuizTreeElement);
}
}
} catch (Exception e) {