result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
finderArgs, this);
}
if (result instanceof Guestbook) {
Guestbook guestbook = (Guestbook)result;
if (!Validator.equals(uuid, guestbook.getUuid()) ||
(groupId != guestbook.getGroupId())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_GUESTBOOK_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_G_UUID_1);
}
else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_G_UUID_3);
}
else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_G_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(groupId);
List<Guestbook> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
finderArgs, list);
}
else {
Guestbook guestbook = list.get(0);
result = guestbook;
cacheResult(guestbook);
if ((guestbook.getUuid() == null) ||
!guestbook.getUuid().equals(uuid) ||
(guestbook.getGroupId() != groupId)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
finderArgs, guestbook);
}
}
}