result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_TOKEN,
finderArgs, this);
}
if (result instanceof LFTincanClientApiStorage) {
LFTincanClientApiStorage lfTincanClientApiStorage = (LFTincanClientApiStorage) result;
if (!Validator.equals(token, lfTincanClientApiStorage.getToken())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(3);
query.append(_SQL_SELECT_LFTINCANCLIENTAPISTORAGE_WHERE);
boolean bindToken = false;
if (token == null) {
query.append(_FINDER_COLUMN_TOKEN_TOKEN_1);
} else if (token.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_TOKEN_TOKEN_3);
} else {
bindToken = true;
if (token.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_TOKEN_TOKEN_3);
} else {
query.append(_FINDER_COLUMN_TOKEN_TOKEN_2);
}
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindToken) {
if (token != null) {
qPos.add(token);
}
}
List<LFTincanClientApiStorage> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
finderArgs, list);
} else {
if ((list.size() > 1) && _log.isWarnEnabled()) {
_log.warn(
"LFTincanClientApiStoragePersistenceImpl.fetchByToken(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.");
}
LFTincanClientApiStorage lfTincanClientApiStorage = list.get(0);
result = lfTincanClientApiStorage;
cacheResult(lfTincanClientApiStorage);
if ((lfTincanClientApiStorage.getToken() == null) ||
!lfTincanClientApiStorage.getToken().equals(token)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
finderArgs, lfTincanClientApiStorage);
}
}
} catch (Exception e) {