result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DOCUMENTID,
finderArgs, this);
}
if (result instanceof LFTincanLrsDocument) {
LFTincanLrsDocument lfTincanLrsDocument = (LFTincanLrsDocument) result;
if (!Validator.equals(documentId,
lfTincanLrsDocument.getDocumentId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_SELECT_LFTINCANLRSDOCUMENT_WHERE);
boolean bindDocumentId = false;
if (documentId == null) {
query.append(_FINDER_COLUMN_DOCUMENTID_DOCUMENTID_1);
} else if (documentId.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_DOCUMENTID_DOCUMENTID_3);
} else {
bindDocumentId = true;
if (documentId.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_DOCUMENTID_DOCUMENTID_3);
} else {
query.append(_FINDER_COLUMN_DOCUMENTID_DOCUMENTID_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindDocumentId) {
if (documentId != null) {
qPos.add(documentId);
}
}
List<LFTincanLrsDocument> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DOCUMENTID,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFTincanLrsDocumentPersistenceImpl.fetchByDocumentId(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.");
}
LFTincanLrsDocument lfTincanLrsDocument = list.get(0);
result = lfTincanLrsDocument;
cacheResult(lfTincanLrsDocument);
if ((lfTincanLrsDocument.getDocumentId() == null) ||
!lfTincanLrsDocument.getDocumentId()
.equals(documentId)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DOCUMENTID,
finderArgs, lfTincanLrsDocument);
}
}