result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_AGENTIDANDPROFILEID,
finderArgs, this);
}
if (result instanceof LFTincanLrsAgentProfile) {
LFTincanLrsAgentProfile lfTincanLrsAgentProfile = (LFTincanLrsAgentProfile) result;
if (!Validator.equals(agentId, lfTincanLrsAgentProfile.getAgentId()) ||
!Validator.equals(profileId,
lfTincanLrsAgentProfile.getProfileId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_LFTINCANLRSAGENTPROFILE_WHERE);
if (agentId == null) {
query.append(_FINDER_COLUMN_AGENTIDANDPROFILEID_AGENTID_NULL_2);
} else {
query.append(_FINDER_COLUMN_AGENTIDANDPROFILEID_AGENTID_2);
}
boolean bindProfileId = false;
if (profileId == null) {
query.append(_FINDER_COLUMN_AGENTIDANDPROFILEID_PROFILEID_1);
} else if (profileId.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_AGENTIDANDPROFILEID_PROFILEID_3);
} else {
bindProfileId = true;
if (profileId.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_AGENTIDANDPROFILEID_PROFILEID_3);
} else {
query.append(_FINDER_COLUMN_AGENTIDANDPROFILEID_PROFILEID_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (agentId != null) {
qPos.add(agentId.intValue());
}
if (bindProfileId) {
if (profileId != null) {
qPos.add(profileId);
}
}
List<LFTincanLrsAgentProfile> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_AGENTIDANDPROFILEID,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFTincanLrsAgentProfilePersistenceImpl.fetchByAgentIdAndProfileId(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.");
}
LFTincanLrsAgentProfile lfTincanLrsAgentProfile = list.get(0);
result = lfTincanLrsAgentProfile;
cacheResult(lfTincanLrsAgentProfile);
if ((lfTincanLrsAgentProfile.getAgentId() != agentId) ||
(lfTincanLrsAgentProfile.getProfileId() == null) ||
!lfTincanLrsAgentProfile.getProfileId()
.equals(profileId)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_AGENTIDANDPROFILEID,
finderArgs, lfTincanLrsAgentProfile);
}
}