result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CERTIFICATEIDANDACTIVITYNAME,
finderArgs, this);
}
if (result instanceof LFCertificateActivity) {
LFCertificateActivity lfCertificateActivity = (LFCertificateActivity) result;
if (!Validator.equals(certificateID,
lfCertificateActivity.getCertificateID()) ||
!Validator.equals(activityName,
lfCertificateActivity.getActivityName())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFCERTIFICATEACTIVITY_WHERE);
if (certificateID == null) {
query.append(_FINDER_COLUMN_CERTIFICATEIDANDACTIVITYNAME_CERTIFICATEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_CERTIFICATEIDANDACTIVITYNAME_CERTIFICATEID_2);
}
boolean bindActivityName = false;
if (activityName == null) {
query.append(_FINDER_COLUMN_CERTIFICATEIDANDACTIVITYNAME_ACTIVITYNAME_1);
} else if (activityName.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_CERTIFICATEIDANDACTIVITYNAME_ACTIVITYNAME_3);
} else {
bindActivityName = true;
if (activityName.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_CERTIFICATEIDANDACTIVITYNAME_ACTIVITYNAME_3);
} else {
query.append(_FINDER_COLUMN_CERTIFICATEIDANDACTIVITYNAME_ACTIVITYNAME_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (certificateID != null) {
qPos.add(certificateID.longValue());
}
if (bindActivityName) {
if (activityName != null) {
qPos.add(activityName);
}
}
List<LFCertificateActivity> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CERTIFICATEIDANDACTIVITYNAME,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFCertificateActivityPersistenceImpl.fetchByCertificateIDAndActivityName(Long, 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.");
}
LFCertificateActivity lfCertificateActivity = list.get(0);
result = lfCertificateActivity;
cacheResult(lfCertificateActivity);
if ((lfCertificateActivity.getCertificateID() != certificateID) ||
(lfCertificateActivity.getActivityName() == null) ||
!lfCertificateActivity.getActivityName()
.equals(activityName)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CERTIFICATEIDANDACTIVITYNAME,
finderArgs, lfCertificateActivity);
}
}