result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PACKAGEANDID,
finderArgs, this);
}
if (result instanceof LFActivity) {
LFActivity lfActivity = (LFActivity) result;
if (!Validator.equals(packageID, lfActivity.getPackageID()) ||
!Validator.equals(id, lfActivity.getId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFACTIVITY_WHERE);
if (packageID == null) {
query.append(_FINDER_COLUMN_PACKAGEANDID_PACKAGEID_NULL_2);
} else {
query.append(_FINDER_COLUMN_PACKAGEANDID_PACKAGEID_2);
}
boolean bindId = false;
if (id == null) {
query.append(_FINDER_COLUMN_PACKAGEANDID_ID_1);
} else if (id.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_PACKAGEANDID_ID_3);
} else {
bindId = true;
if (id.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_PACKAGEANDID_ID_3);
} else {
query.append(_FINDER_COLUMN_PACKAGEANDID_ID_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (packageID != null) {
qPos.add(packageID.intValue());
}
if (bindId) {
if (id != null) {
qPos.add(id);
}
}
List<LFActivity> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PACKAGEANDID,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFActivityPersistenceImpl.fetchByPackageAndID(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.");
}
LFActivity lfActivity = list.get(0);
result = lfActivity;
cacheResult(lfActivity);
if ((lfActivity.getPackageID() != packageID) ||
(lfActivity.getId() == null) ||
!lfActivity.getId().equals(id)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PACKAGEANDID,
finderArgs, lfActivity);
}
}
} catch (Exception e) {